Shop OBEX P1 Docs P2 Docs Learn Events
WRITING and SAVING BS2 — Parallax Forums

WRITING and SAVING BS2

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

Comments

  • You will need to teach your bs2 to how to tell time. To do that, you will need to equip it with a clock. Search under RTC or GPS for many threads about that.
  • kwinnkwinn Posts: 8,697
    IIRC this project is to use a BS2, CY T16 V1.1, and time from a GPS receiver to replace the current annunciator. Is that what you want to do?

    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.
  • Hi guys thanks for the reply really appreciate it. By the way this is our codes for playing our mp3 module using basic stamp. Is it possible to save 96 different alarms per day within a month?


    ' {$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

  • kwinnkwinn Posts: 8,697
    cydelcamat wrote: »
    ....

    Is it possible to save 96 different alarms per day within a month?


    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.
  • so we can do it by using serial eeprom like 24C1024 kwinn?
  • kwinnkwinn Posts: 8,697
    It probably can be done with the 24C1024 but it depends on how you implement the schedule. Best case it could take as little as 5 bytes per event:

    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.
  • kwinnkwinn Posts: 8,697
    To make the program as simple and efficient as possible we need some details on the typical schedule data and the source and format of the time.
  • The source of the time will be the gps module that throws to basic stamp 2 a NMEA code then the time format will be 24hr format with hours minutes and seconds...
  • Mr.Kwinn we`re looking forward to your reply tomorrow. Is it so hard for us that we`re in different time zone :(
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    Here are a couple of projects that handle alarms and/or events based on time. Both use the DS1302 RTC and both store information in the NVRAM within the DS1302.

    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
  • kwinnkwinn Posts: 8,697
    cydelcamat wrote: »
    ' {$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
    

    Is this all the code you have for this project so far?
  • kwinnkwinn Posts: 8,697
    I need the following information in order to help you with this.

    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.
Sign In or Register to comment.