Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:28 16 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Micromite Pulse v5.1

Author Message
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 982
Posted: 08:53pm 25 Feb 2016
Copy link to clipboard 
Print this post

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.
GMEdited by Graeme Meager 2016-02-27
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 982
Posted: 06:27pm 26 Feb 2016
Copy link to clipboard 
Print this post

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: Australia
Posts: 1000
Posted: 07:44pm 26 Feb 2016
Copy link to clipboard 
Print this post

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
GerryEdited by disco4now 2016-02-28
Latest F4 Latest H7 FotS
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6270
Posted: 07:55pm 26 Feb 2016
Copy link to clipboard 
Print this post

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: Australia
Posts: 982
Posted: 10:37pm 26 Feb 2016
Copy link to clipboard 
Print this post

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
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025