![]() ![]() So it is just running the setup routine over and over. I say the infinite loop is in setup because when I run the code, in the serial monitor I get Begining Program! / then the next one calls after a period of time to reset the voltge and the interlock - not implemented yet / next part runs a subroutine to incriment voltage after a period of time ![]() / 3 parts, main loop constantly reads in voltage Incriment the counter one and step up voltage reset interlock signal here( to be added later) Resets the counter for 0 for the DAC and sets voltage to 0, to be turned into an interupt later ![]() set compare match register to desired timer count: TIMER PORTION PULLED DIRECTLY FRMOM TUTORIAL Anyone either see what I am doing wrong, or think I'm stupid and have a far simpler way of doing it? Either option is acceptable. I have no idea why the setup() is looping, and the compiled program is only 5kb out of 32kb the uno can hold. I am using some timers for the slow increase in voltage, using the tutorial found here : but when I copy in the parts of the code he uses for timing my setup() runs in an infinite loop. I want to use interrupt driven programming so that when my system sparks it is caught regardless of where in the loop I am and I can ramp down the voltage safely. Serial.I am trying to use an ardunio to control two DAC chips to output a slowly increasing voltage that is connected to a 50kV power supply for some science stuff. Volatile int millisDelta = 0 // to store deltas Volatile int millisOld = 0 // to store prev time Volatile int millisNew = 0 // to store up to date time Volatile int LEDFlashState = 0 // init 0 - variable to flip when LED on Volatile int nStepTask1ms = 0 // init 0 - to be used for counting number of 1ms tasks run and hence calling 10ms task It's driven from interrupts so it should surely just drop the comms and perform the next ISR - effectively a task overrun. ** Although I don't get how Serial.println manages to slow the program down. *Whilst not what I'm confused about - any comments on my logic here also welcome I suppose chewing through a few characters at 9600baud probably is quite slow.** What's also throwing a spanner in the works is that using serial comms to try and debug the faster task rates seems to slow things down considerably, so I'm inferring the problem by counting up 1ms tasks to call 10,1ms tasks and debugging at the slower level. I've been confused for hours on this but I'm prepared to accept it could be something fundamental/basic! I've done something similar using millis() and whilst that worked I found it inelegant that a) there was no obvious way to check for task overruns and backing-up the execution rate and b) the processor is bunged up by checking millis() every program cycle.*Įssentially what I think should be a 1ms timer interrupt on Timer2 (16MHz/64 prescaler /250 compare register =1000hz) is coming out around 0.5ms. I have written the below sketch as a stab at a rigid framework for executing different fcns at different rates. I have no specific goal here other than learning something that I think would be useful feather to add to my cap! ![]() I'm looking for some assistance please with something that has been confusing me whilst trying to learn timer interrupts ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |