Hello!! New user trying to programm a nanjg 105c!!

Hello guys!!

New user here! I have been reading the forum for a long time and for the last 6 weeks I have been trying to program a nanjg 105 driver!!
I succeeded to flash sixty545 8 mode program and Tido simple one but with on all other programs there is no success for me!!

So I decided to register and get some help!!!

Have a nice day all of you!!

Welcome to BLF! Ok, so where exactly does it go wrong?

<— too lazy to try yet, my programmer hooked up to the ATtiny13C for maybe a week? 0:)

What seems to be the problem georgek?

You have come to the right place, georgek!

Hi guys!! thanks a lot for the warm welcome…

also excuse my english as it is not my mother language…

so… I use avr studio5, burn o mat, usbasp and I also tried avrstudio4, eclipse, winavr, khazama, and extreme burner…

I have read the thread tido made about perfect modes lots of times and also the flashlightwiki about avr drivers…

I followed every step. I use the driver.c from blf-vld to set the modes I want and then compile it into simple…
It compiles ok, it builds ok with no errors and It alsi burns.and veryfies ok…

so everything seems fine but nothing works… also I verify the fuse…
after every unsaccesfull attempt I reupload sixtys545 8 mode program and worka great…

what I want is a program with no memory and 5–12,5–25–50–65–100…

nothing fancy as you can see…

also it would be nice to have battery warning but lets be real, I have no experience about this type of things and I study completely different science… so the simple 6 mode driver with no memory is perfectly fine for me!!

also the only experience I have is what I read from the forum, tidos thread and flashlightwiki and unfortunately I dont have the time for a lot more… :frowning:

so be gentle guys…
what am I doing wrong???

ok, let me write down exactly what I am doing, so you can tell me where I am wrong:

1. open driver.c from Tido’s BLF-VLD, select all and copy.

2. open AVRStudio 5, and make a new project

3. Paste over what I copied from driver.c

4. change to my prefered settings as sixty545 posted here

and then press compile on the avrstudio toolbar

I think I may found what I am doing wrong, can anyone please explain to me in details how to compile??

yes I have read the whole thread about perfect modes but I don’t seem to understand the compile thing…

5. then I burn the hex and eep using burn o mat into the chip and verify them. at this point everything seems fine.

6. I now try to test the light but nothing happens, it does not even light up.

is it a kaidomain driver? ( i think you cant flash those)

“Compile” is the phase where a computer program converts your program instructions (or Tido’s) from a form you and I can read (that being “driver.c” in this case) into a form the computer can read. In essence, the MCU is a tiny computer. In a larger program, this phase “compiles” all the different sub-modules into one big happy file.

The likely culprit is punctuation. Your compiler program probably gives you some kind of error message. It may be either on the screen or in some list file in the same folder as your project. That (those??) error message describes the problem perfectly.

Second-likely since the “stock” code works, is a misspelling. These can be hard to spot unless the compiler is pretty specific in its error messages. Again, what error message ( s ) do you get when you click the button?

I think you see the point. What error message, please, cut-&-paste if possible?

Good luck!

Dim

Hello again,

No it is not a kd driver…

it is a nanjg105c with attiny13a…

no error msg…

i get this

Build started.
Project “driver.cproj” (Compile target(s)):
Target “Compile” in file “C:Program FilesAtmelAtmel Studio 6.0VsCompiler.targets” from project “C:UsersgeorgeDocumentsAtmel Studiodriverdriver.cproj” (entry point):
Task “RunCompilerTask”
C:Program FilesAtmelAtmel Studio 6.0makemake.exe “driver.o”
Building file: …/./driver.c
Invoking: AVR/GNU C Compiler : (AVR_8_bit_GNU_Toolchain_3.4.0_663) 4.6.2
“C:Program FilesAtmelAtmel Studio 6.0extensionsAtmelAVRGCC3.4.0.65AVRToolchainbinavr-gcc.exe” -funsigned-char -funsigned-bitfields -O1 -fpack-struct -fshort-enums -g2 -Wall -c -std=gnu99 -MD -MP -MF “driver.d” -MT”driver.d” -MT”driver.o” -mmcu=attiny13a -o”driver.o” “…/./driver.c”
In file included from …/./driver.c:28:0:
Finished building: …/./driver.c
Done executing task “RunCompilerTask”.
Done building target “Compile” in project “driver.cproj”.
Done building project “driver.cproj”.

Build succeeded.

Guys I am thinking to give up…
I have been fighting with this for weeks now and today I have done it again and again for i don’t know how many times…

It took me so much time.

Guys, I don’t use BLF-VLD or DrJones programs, and I don’t even have AVRStudio installed on my laptop…

But, I know lots of you do. Someone send a copy of a (working) compiled hex/eep to OP so that he can see if the failure is in code/compiling or burn/programming.

If you need an easy way to send him the files, zip them up and drop them at
www.brightlightmodules.com/BLF

PPtk

Burning is not my problem for sure as I can burn the programs on the chip but the only ones I get to work are the sixty545 8 mode program and Tido’s simple… *I have burned tidos default and fixed also with success so it seems that the luch of programming knowledge is the problem for me…

I just can’t figure out what to do and how to do my program using tido’s files…

Whatever I do seems ok but when I burn it it doesn’t work…

If anyone can make or have ready a working program of 5–15–30–50–100% without memory and share it or a simple driver.c file that can be easily modified it would be great…

As it seems I can only burn already working hex and eep files fine but I do not manage to modify a c file with success…

I feel your pain. I finally installed all the software and need to read through that daunting thread. 600+ posts in that thread and info scattered all throughout. It would be wonderful if someone with experience would write a fresh step-by-step thread on how to do it from beginning to end. I'm sure I'm not the only one who appreciate the time taken.

georgek, didn’t the new luxdrv source with the changes I PMed you work?

Dr Jones I have been trying from the time I have read the pm you send me to find the lines but with no luck. Two are the possible situations, I am blind or something is wrong with the file I have…

Take a loom please…

I am pasting your luxdrv3.0

//
// LuxDrv 0.30 DrJones 2011
//
// 994 bytes with ramping and timer
//
// License: Free for private and noncommercial use for members of BudgetLightForum
//
// changes:
// 0.1 first version: levels,strobe,beacon,timer(136) (638bytes)
// 0.2 ramping(200), improved timer(180), skip mode1 as next mode if already in mode 1 (898bytes)
// 0.21 changed EEPROM handling to reduce power-off-while-writing glitches —>eepsave(byte) (874bytes)
// 0.22 bugfix in ramping; mode not stored on (very) short tap (878bytes)
// 0.3 battery monitoring added; step down and indicator in beacon mode (994bytes)

//ToDo:
// ? off-time checking; requires adding diode,R,C
// ? blink your name in morse code :slight_smile:

#define outpin 1
#define PWM OCR0B //PWM-value

#define adcpin 2
#define adcchn 1

#define portinit() do{ DDRB=(1<<outpin); PORTB=0xff~~~~(1<<adcpin); }while(0)

#include <avr/pgmspace.h>
#define byte uint8_t
#define word uint16_t

//########################################################################################### MODE/PWM SETUP

//251, 252, 253, 254 are special mode codes handled differently, all other are PWM values

#define F_CPU 4800000 //CPU: 4.8MHz PWM: 9.4kHz ####### use low fuse: 0x75 #######
PROGMEM byte modes={ 0, 6,51,255, 254, 251, 252, 253 }; // with ramping
// dummy main modes ramping, ramped mode, strobe, beacon, timer
#define TIMER 5 //use timer (5 min, max 6 in this setup)
#define RAMPING //use ramping
#define MINPWM 5 //needed for ramping
#define RAMPMODE 4 //the number of the ramping mode (254) in the modes order; e.g. ramping is 4th mode -> 4; not counting dummy
#define LOCKTIME 12 //time in 1/8 s until a mode gets locked. 12/8=1.5s
#define BATTMON 125//enable battery monitoring with this threshold

//PROGMEM byte modes={ 0, 6,51,255, 5,6,14,37,98,255, 251, 252, 253 }; // 9kHz modes, 5 is lowest, no ramping
//// dummy main modes more levels strobe,beacon,timer

//###########################################################################################

#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <avr/eeprom.h>

#define WDTIME 0b01000011 //125ms

#define sleepinit() do{ WDTCR=WDTIME; sei(); MCUCR=(MCUCR &~0b00111000)|0b00100000; }while(0) //WDT-int and Idle-Sleep

#define SLEEP asm volatile (“SLEEP”)

#define pwminit() do{ TCCR0A=0b00100001; TCCR0B=0b00000001; }while(0) //chan A, phasePWM, clk/1 ->2.35kHz@1.2MHz

#define adcinit() do{ ADMUX =0b01100000|adcchn; ADCSRA=0b11000100; }while(0) //ref1.1V, left-adjust, ADC1/PB2; enable, start, clk/16
#define adcread() do{ ADCSRA|=64; while (ADCSRA&64); }while(0)
#define adcresult ADCH

#define ADCoff ADCSRA&=~(1<<7) //ADC off (enable=0);
#define ADCon ADCSRA|=(1<<7) //ADC on
#define ACoff ACSR|=(1<<7) //AC off (disable=1)
#define ACon ACSR&=~(1<<7) //AC on (disable=0)

//_

volatile byte mypwm=0;
volatile byte ticks=0;
volatile byte mode=1;
byte pmode=50;

byte eep[32]; //EEPROM buffer
byte eepos=0;

#ifdef RAMPING
byte ramped=0;
#endif

byte lowbattcounter=0;

void eepsave(byte data) { //central method for writing (with wear leveling)
byte oldpos=eepos;
eepos=(eepos+1)&31; //wear leveling, use next cell
EEARL=eepos; EEDR=data; EECR=32+4; EECR=32+4+2; //WRITE //32:write only (no erase) 4:enable 2:go
while(EECR & 2); //wait for completion
EEARL=oldpos; EECR=16+4; EECR=16+4+2; //ERASE //16:erase only (no write) 4:enable 2:go
}

inline void getmode(void) { //read current mode from EEPROM and write next mode

eeprom_read_block(&eep, 0, 32); //+44 //read block
while((eep[eepos]==0xff) && (eepos<32)) eepos; //+16 //find mode byte
if (eepos<32) mode=eep[eepos];
else eepos=0; //+6 //not found

byte next=1;
if (mode==1) next=2; //+10

#ifdef RAMPING
if (mode & 0x40) { //RAMPING
ramped=1;
if (mode & 0x80) { next=RAMPMODE+1; mode&=0x7f; } //mode: for savemode
//else next=1
}else //ENDRAMPING
#endif

if (mode & 0x80) { //last on-time was short
mode&=0x7f; if (mode>=sizeof(modes)) mode=1;
next=mode+1; if (next>=sizeof(modes)) next=1;
} //else next=1; //previous mode was locked, this one is yet a short-on, so set to restart from 1st mode.

eepsave(next|0x80); //write next mode, with short-on marker
}

ISR (WDT_vect) { //WatchDogTimer interrupt
if (ticks<255) ticks;
if (ticks==LOCKTIME) eepsave(mode); //lock mode after 1.5s

#ifdef BATTMON //code to check voltage and ramp down
adcread();
if (adcresult<BATTMON) { if (++lowbattcounter>8) {mypwm=(mypwm>>1)+3;lowbattcounter=0;} }
else lowbattcounter=0;
#endif
}

int main(void) {

portinit();
sleepinit();
ACoff;
#ifdef BATTMON
adcinit();
#else
ADCoff;
#endif
pwminit();

getmode(); //get current mode number from EEPROM

byte i=0;

#ifdef RAMPING
byte p,j=0,dn=1; //for ramping

if (ramped) { //use the ramped mode
pmode=255; i=30-MINPWM~~; while(i—){pmode=pmode~~(pmode>>3)–1;} //get PWM value //never gives 250…254
} else
#endif

pmode=pgm_read_byte(&modes[mode]); //get actual PWM value (or special mode code)

switch(pmode){

case 251: mypwm=255; while(1){ PWM=mypwm; _delay_ms(20); PWM=0; _delay_ms(60); } break; //strobe 12.5Hz //+48

case 252:
#ifdef BATTMON
adcread(); i=adcresult; while (i>BATTMON) {PWM=8; SLEEP;SLEEP; PWM=0; SLEEP; i-=5;} SLEEP;SLEEP;SLEEP;
#endif
mypwm=255; while(1){ PWM=mypwm; _delay_ms(20); PWM=0; i=70;do{SLEEP;}while(—i); } break; //beacon 10s //+48

#ifdef TIMER
case 253: i=TIMER; do{ //+180
byte j=i; do{PWM=255; _delay_ms(20); PWM=0; _delay_ms(300); }while(—j); //blink remaining minutes
byte k=30; do{ byte m=0; do{ //wait 1 minute
if (m<i) {_delay_ms(233);PWM=8;_delay_ms(90);PWM=0;}
else _delay_ms(333);
}while(++m<6); }while(—k);
}while(—i); //for TIMER min
i=100; do{ PWM=255; _delay_ms(30); PWM=0; _delay_ms(70); }while(—i); //strobe 10s
while(1){PWM^=8;SLEEP;} //”off”
break;
#endif

#ifdef RAMPING
case 254: ticks=100; //crude way to deactivate the 2s-lock //RAMPING
while(EECR & 2); //wait for completion of getmode’s write
while(1){ p=255; i=30-MINPWM-j; while(i—){p=p-(p>>3)–1;} //ramp up
PWM=p;
eepsave(192+j);
SLEEP;
if (dn) {if (j ) j—; else {dn=0;SLEEP;SLEEP;} }
else {if (j<30-MINPWM) j; else {dn=1;SLEEP;SLEEP;} } //wear leveling
} break;
#endif

default: mypwm=pmode; while(1){PWM=mypwm;SLEEP;} //all other: us as PWM value

//mypwm: prepared for being ramped down in WDT on low-batt condition.

}//switch
return 0;
}//main

Johny,

I have read through the thread more than 5 times but i don’t seem to have any success…

I can admit that I learned how to burn the hex and eep into the chip and verify them…

But they have to be tested and working from someone experienced. The 8mode sixty545 made,the simple, default, and fixed from tido and the luxdrv1 from drJones(but for this I get only one low mode, I dont know why).

DrJone even told me which line to modify but I was not able to even find the lines int the file all day today (I think that there is something wrong with the file I have or I will need to have my eyes checked)

You got the old version of luxdrv, download it again…

How stupid am I??

I have been trying all day to find something tha didn’t exist in the file…
hahaha fortunately I won’t need to have my eyes checked!!

I will download it 2morrow cause I am on a mobile now and build the hex and eep and try it out!! I hope it will work!!

Thanks a lot drJones!!!

You Guys here I blf are the best!!!

Thanks to everyone especially DrJones, The Ninja Guy and Sixty545 for helping me so much!!!

You guys rock!!!

Missed this thread.
A formal welcome to you georgek.
You made a great choice joining BLF. Everyone is very nice and willing to help. We are like one big family. :slight_smile: