WRITING and SAVING BS2
cydelcamat
Posts: 53
in BASIC Stamp
hi guys. Does anyone here has an experience on writing and saving data in basic stamp?
This is an example code for HIGH and LOW program. I want to add a specific time for each event. for example. I want my pin to be HIGH at exactly 10:00 am. Can you guys help me? THANKS!
Main:
HIGH 0
PAUSE 500
LOW 0
PAUSE 500
GOTO Main
END
This is an example code for HIGH and LOW program. I want to add a specific time for each event. for example. I want my pin to be HIGH at exactly 10:00 am. Can you guys help me? THANKS!
Main:
HIGH 0
PAUSE 500
LOW 0
PAUSE 500
GOTO Main
END
Comments
To perform specific events at specific times you would need to compare the actual time to the specific time you want an event to occur and call a subroutine to perform the action when the two times are equal.
The code depends on the formats of the schedule time and actual time.
' {$STAMP BS2}
' {$PBASIC 2.5}
OUTPUT 19
INPUT 11
T1200 CON 813
T2400 CON 396
T4800 CON 188
T9600 CON 84
T19K2 CON 32
T38K4 CON 6
SevenBit CON $2000
Inverted CON $4000
Open CON $8000
Baud CON T9600 + Inverted
cmd_buff VAR Byte
cmd_buff2 VAR Byte
reps VAR Nib
main:
'SERIN 5, T4800, [cmd_buff2]
'DEBUG cmd_buff2
SERIN 16, 84, [cmd_buff]
IF cmd_buff = "A" THEN
SEROUT 14, T9600, [$7E, $FF, $06, $11, $00, $00, $01, $FE, $E9, $EF]
ELSEIF cmd_buff = "a" THEN
SEROUT 14, T9600, [$7E, $FF, $06, $0E, $00, $00, $00, $FE, $ED, $EF]
ENDIF
IF cmd_buff = "B" THEN
SEROUT 14, T9600, [$7E, $FF, $06, $01, $00, $00, $00, $FE, $FA, $EF]
ELSEIF cmd_buff = "b" THEN
SEROUT 14, T9600, [$7E, $FF, $06, $02, $00, $00, $00, $FE, $F9, $EF]
ENDIF
GOTO main
By this do you mean 96 x 31 alarms that are updated each month or 96 x days/month x 12 months for a total of 35,040 alarms?
A 128KB eeprom could possibly hold 2976 (96 x 31) alarms, but 35,040 might be a bit too much.
1 byte for the day
4 bytes for the time
4 bytes for the command
That would fit up to 26,214 commands in the eeprom.
http://savagecircuits.com/index.php/projects/basic-stamp-projects/22-digital-thermostat
http://savagecircuits.com/index.php/projects/basic-stamp-projects/25-digital-alarm-clocks
Is this all the code you have for this project so far?
1 : Sample NMEA sentences from your GPS unit or at least the type of sentence used.
For example the ZDA sentence would look like this:
$GPZDA,160012.71,11,03,2004,-1,00*7D
2 : A sample of the schedule data the PC software sends to your current PIC micro.
This may be available in the software manual or you may need to intercept it as it is downloaded from the PC to the PIC.
3 : Where the RX and TX signals from the GPS and the PC connect to on the BS2.
This would be the I/O port numbers (called P0 to P15), not the actual pin number of the chip.
PS – If you have any additional pbasic code for this project you can send that as well.