![]() |
Forum Index : Microcontroller and PC projects : Micromite Pulse v5.1
Author | Message | ||||
OA47 Guru ![]() Joined: 11/04/2012 Location: AustraliaPosts: 982 |
Not sure if I have missed something but when I pulse an led at 1 or 2 milliseconds all is ok but if I pulse 3ms or more then the led stays active. Any clues? Just found that it seems to be a re-action to a CPU SLEEP 2 line that proceeds the pulse line. GM |
||||
OA47 Guru ![]() Joined: 11/04/2012 Location: AustraliaPosts: 982 |
I would like another backshedder to confirm my problem if possible. (I think Geoff is still in his campervan somewhere) I will attach some code that I am using but I think that a single colour LED would do for the test and you could strip out the lines to do with the analog reading and the modulation of the two LEDs. '************************************************************* '* THIS PROGRAM WILL MONITOR THE STATE OF A 12 VOLT BATTERY * '* AND FLASH A TRI COLOR LED GREEN For >12.5V, AMBER BETWEEN * '* 12 And 12.5 V And RED BELOW 12V. * '* USING THE MCP1703 REGULATOR CURRENT DRAW IS MICROAMPS/HR * '* * '* MMBASIC 5.1 For MICROMITE II WITH OPTION AUTORUN ON * '* * '* THANKS TO GEOFF GRAHAM FOR ALL OF HIS WORK FEB 2016 * '************************************************************* Option EXPLICIT Dim BLNK,CAL,VOLTS,URG SetPin 14,DOUT 'RED LED ANODE SetPin 15,DOUT 'GREEN LED ANODE SetPin 23,AIN '10K/100K RESISTOR DIVIDER BLNK=3 'LED PULSE LENGTH CAL=11.26 'ANALOG CALIBRATION START: CPU SLEEP 3 'PUT UNIT TO SLEEP FOR APPROX 3 SECONDS VOLTS=0.6+Pin(23)*CAL 'CALIBRATED FOR RESISTOR DIVIDER & PROTECTION DIODE URG=1+(VOLTS-12)*2 'URG MANAGES THE AMOUNT OF RED/GREEN MIX Print VOLTS 'USED TO CALIBRATE DIVIDER If VOLTS > 12.5 Then Pulse 15,BLNK 'FLASH GREEN If VOLTS > 12 And VOLTS < 12.5 Then 'FLASH AMBER Pulse 15,BLNK Pulse 14,BLNK/URG End If If VOLTS < 12 Then Pulse 14,BLNK 'FLASH RED GoTo START |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1000 |
Graeme, I have not tried you code but there might be a clue in the manual entry for PULSE that could help. It seems a pulse of less than 3ms is run in the foreground, so basic waits for it to finish, but 3ms or more are run in the background.I think this means your basic code will queue the pulse command for background and keep going and the next thing it does is put the CPU to sleep. The pulse is happening in the background , I am guessing it gets as far a turning on, but by then basic has put the CPU to sleep so it never gets to finish of the off part of the pulse. You could try a PAUSE 4 (4ms) before the CPU SLEEP to give the Pulse time to complete in the background. You also need a PULSE pin,0 to tell it to stop doing the pulse in the background. Just a theory. Regards Gerry Latest F4 Latest H7 FotS |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6270 |
Gerry beat me to it. I setup a test with the CRO and the pulses were getting cut short as soon as the CPU went to sleep. This seemed to confuse the pulse polarity and we ended up with short negative going pulses. PAUSE BLNK+1 before the SLEEP makes a big difference. Lucky I didn't have AUTORUN on because it is difficult to break out of a SLEEPing program. Jim VK7JH MMedit |
||||
OA47 Guru ![]() Joined: 11/04/2012 Location: AustraliaPosts: 982 |
Thanks Jim and Gerry, it seems the BLNK+1 before the SLEEP is the way to fix the problem. Seems to work flawlessly now. GM |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |