Using internal 18M2 timer to display time

JonRen

New Member
Hi there,

I was wondering if someone could help me with regards to using the internal timer of an 18M2 chip. I'm currently using the chip to turn on different coloured LEDs when different inputs are turned on. Eventually I'll hook it up to 3 input devices which will be running for an hour and half process and if one of them turns off (which they shouldn't) then a red LED will display and also an OLED screen will display which input it is which has turned off.

However, I was hoping there might be a way of using the internal timer of the 18M2 chip to display exactly when this input 'failed' so that I can see how far along the process it did fail so that I know how much longer the process should be restarted from.

Sorry if there is an obvious explanation but I'm still new to this and could definitely use some help!

Thanks very much!

Jon.
 

hippy

Ex-Staff (retired)
You could probably just copy the 'time' variable into another variable at the time you detect the failure, "let w7 = time", then display that variable as a time.
 

JonRen

New Member
Hi hippy thanks for the reply. Sorry if this sounds a bit dim but how would I display the variable w7 for example. Like how would I convert that into code to display on an OLED?
 

hippy

Ex-Staff (retired)
BINTOASCII splits a number into separate numerical digits. You might want to convert the variable in seconds into hours, minutes and seconds, so you could do that then split each into digits.

hour = timeSecs / 3600
mins = timeSecs // 3600 / 60
secs = timeSecs // 60
 
Top