Shop OBEX P1 Docs P2 Docs Learn Events
Full Duplex Serial Plus -- Memory Storage Management — Parallax Forums

Full Duplex Serial Plus -- Memory Storage Management

172heavy172heavy Posts: 55
edited 2012-10-13 12:12 in Propeller 1
Hello! It has been a while since I have had the pleasure to develop with my propeller, I am still fairly green so these may be basic questions please go easy.....
1. Full Duplex Serial Plus Object--I am trying to receive a 6digit decimal value for some reason it keeps truncing anything over 5 digits or dec value of 65535. I am assuming that the buffer size is the issue i see the [16] where the variable size is declared. Is this the size of the buffer? If so why can't i make it larger? If i can how do i do this?

**************I figured number one out, I told you guys it had been a while...the variable I was using to store the value was declared as a WORD! So it makes sense that the value of the ID was limited to 65535*********************************

2. Can i use the Memory Storage Management Obj to store data on the prop EEPROM? I only need to store approx 50 to 75 6 digit numbers. I need to compare them to the RFID value the a card or FOB id presented.

This is solved. I used the propeller EEPROM object. Thanks for the feedback!

If there is an easier way I am all ears...... I am going to go back through the PE kit tonight and brush up.

Thanks.

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-10-10 17:32
    172heavy wrote: »
    Hello! It has been a while since I have had the pleasure to develop with my propeller, I am still fairly green so these may be basic questions please go easy.....
    1. Full Duplex Serial Plus Object--I am trying to receive a 6digit decimal value for some reason it keeps truncing anything over 5 digits or dec value of 65535. I am assuming that the buffer size is the issue i see the [16] where the variable size is declared. Is this the size of the buffer? If so why can't i make it larger? If i can how do i do this?

    2. Can i use the Memory Storage Management Obj to store data on the prop EEPROM? I only need to store approx 50 to 75 6 digit numbers. I need to compare them to the RFID value the a card or FOB id presented.

    If there is an easier way I am all ears...... I am going to go back through the PE kit tonight and brush up.

    Thanks.

    Can i just say that if you had a Forth running that this would be such a trivial matter and that it would take longer to ask than it would take to write and test.
  • 172heavy172heavy Posts: 55
    edited 2012-10-10 17:49
    Can i just say that if you had a Forth running that this would be such a trivial matter and that it would take longer to ask than it would take to write and test.

    What is Forth? I will follow your link.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-10-10 17:59
    172heavy wrote: »
    What is Forth? I will follow your link.
    The RFID tag from Parallax outputs ten digits preceded by a LF and terminated by a CR. Forth automatically accepts any number in any base and pushes the numbers onto a stack. However a simple one line program could request to get a number from the input stream, check it and process it, even accessing the EEPROM as a number memory if you like. I could show you how this would be done so simply in Forth but I probably would need a few more details from you.
  • cavelambcavelamb Posts: 720
    edited 2012-10-10 18:13
    Peter,

    Can you describe Forth is 25 words or less? Or maybe a few more?

    But what is it all about?
  • 172heavy172heavy Posts: 55
    edited 2012-10-10 18:27
    The RFID tag from Parallax outputs ten digits preceded by a LF and terminated by a CR. Forth automatically accepts any number in any base and pushes the numbers onto a stack. However a simple one line program could request to get a number from the input stream, check it and process it, even accessing the EEPROM as a number memory if you like. I could show you how this would be done so simply in Forth but I probably would need a few more details from you.

    I am actually using an RFID reader from RFIDEAS it is the PC prox, it is sending the data in decimal format I have set up the reader to send only the Card ID number and a CR. The id numbers are 5 to 6 digits long.

    I would be interested in learning a little about FORTH I went to your website and it looks quite interesting. The project is pretty basic.

    1. Enroll Cards- I plan to have a jumper on the board to trigger a method that will save all ID's which are scaned to a list of approved cards.
    2. Read Cards-Each card that is presented to the reader will be read and have it's ID compared with the enrollment list. If approved go to step 3....
    3. Send output to close relay which will bypass--or simulate--the pressing of the switch on the garage door opener that we use to control the gate to access the facility.
    4. I will probably integrate some LEDs for good and bad scans or non authorized cards etc.

    I loaded TACHYON on my prop chip and I am following your tutorial on the link you provided. I am using the Prop Serial Tool, each time I press the space bar it acts like I enter the CR key and replies with ???, I wonder if this is an issue with the TERM or what?
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-10-10 19:04
    172heavy wrote: »
    I am actually using an RFID reader from RFIDEAS it is the PC prox, it is sending the data in decimal format I have set up the reader to send only the Card ID number and a CR. The id numbers are 5 to 6 digits long.

    I would be interested in learning a little about FORTH I went to your website and it looks quite interesting. The project is pretty basic.

    1. Enroll Cards- I plan to have a jumper on the board to trigger a method that will save all ID's which are scaned to a list of approved cards.
    2. Read Cards-Each card that is presented to the reader will be read and have it's ID compared with the enrollment list. If approved go to step 3....
    3. Send output to close relay which will bypass--or simulate--the pressing of the switch on the garage door opener that we use to control the gate to access the facility.
    4. I will probably integrate some LEDs for good and bad scans or non authorized cards etc.

    I loaded TACHYON on my prop chip and I am following your tutorial on the link you provided. I am using the Prop Serial Tool, each time I press the space bar it acts like I enter the CR key and replies with ???, I wonder if this is an issue with the TERM or what?

    If you are using Windows then try the open-source TeraTerm, it's really good. On LInux I am using Miniterm. But yes there is a problem with your terminal by the sounds of it though I have never used this software.

    You know that you can use an indicator LED as a "button". Also you could have a "master" card which is always recognized and toggles the enrolment mode or in combination with a "button" or two then also removes certain cards. But that sounds like a very primitive way to do it as I would just have one of my Bluetooth serial modules embedded with the Prop and communicate to the unit via a laptop or tablet or phone to program and configure it.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-10-10 19:06
    cavelamb wrote: »
    Peter,

    Can you describe Forth is 25 words or less? Or maybe a few more?

    But what is it all about?
    In 25 words or less I could write the RFID program.
  • SRLMSRLM Posts: 5,045
    edited 2012-10-10 20:57
    Can you post your code as an attachment?
  • D.PD.P Posts: 790
    edited 2012-10-10 21:42
    In 25 words or less I could write the RFID program.

    While over on the "Spin Improvements" thread they are arguing about whether we should even have a language (in this case spin) that doesn't have a MAKE file, OMG. And here Peter is gonna start a FORTH riot by acutally helping people in the trenches get'r done.

    Good on you Peter. 25 words, kinda verbose for you isn't it :-/
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-10-10 21:55
    Okay, I could do it in 25 words but I would probably be the only person to understand it! :)
    Here is a far more verbose version I wrote while munching my bagel and sipping my espresso, but it's a complete ready to go turn-key solution. When I get some time I will load it in and check it out with the Parallax RFID reader.
    [FONT=courier new]TACHYON
    {
    Demonstrate how a RFID card reader can be implemented to enroll cards and to check access.
    
    When the enroll switch input is high all cards will be added to the card table and backed up to EEPROM
    The relay will also energize for 1 second
    
    When the enroll switch input is low then all cards will be checked against the card table and if found then
    the relay will be energized for 1 second.
    
    The program can be expanded very easily to output to an LCD or simple indicator LEDs and also a piezo
    }
    
    #P0    CONSTANT #rfid        \ RFID serial input on P0
    #P1    CONSTANT #enroll        \ Mode switch to select enrollment mode
    #P16    CONSTANT #relay        \ A relay is connected via a suitable driver
    #P17    CONSTANT #beeper        \ An optiona piezo or speaker or LED may be attached to this pin 
    
    #1000 CONSTANT cardlimit
    
    HERE $3F + $3F ANDN 1- here W!        \ Align
    \ Create a table of longs for cards in RAM but backed up in EEPROM
    TABLE cards     cardlimit 4 * ALLOT
    cards cardlimit 4 * ERASE
    
    \ Index into the card enrollment table and return with a physical address of a long
    pub CARD ( index -- addr )
        2* 2* cards +
        ;
    
    pub CARD? ( card# -- index flg )
        FALSE cardlimit 0 
        DO 
          OVER I CARD @ = IF 2DROP I TRUE LEAVE THEN 
        LOOP
        ;
    pub ENROLLED? ( card# -- flg )
        CARD? NIP
        ;
    
    \ Find the card in the table and if found then wipe it
    pub REMOVE ( card# -- )
        CARD? IF 0 OVER CARD ! THEN DROP
        ;
    
    \ Find a null entry in the card table and write the card# to it. Return with a success flag unless table is full.
    pub ENROLL ( card# -- flg )
        cardlimit 0 
        DO
          I CARD @ 0= IF I CARD ! 0 LEAVE THEN 
        LOOP        
        0=
        ;
    
    \ Enroll a card if it is not already enrolled but if it is then remove it
    pub EDIT ( card# -- flg )
        DUP ENROLLED? IF REMOVE FALSE ELSE ENROLL THEN
        ;
        
    \ Backup the cards table into EEPROM - automatically loaded on power-up with the rest of the program    
    pub SAVE
        cards DUP cardlimit 4 * ESAVE
        ;
    \ Turn the relay on or off
    pub RELAY ( on/off -- )
        #relay PIN!
        ;
    
    \ RFID serial input routine
    pub RFID
        #rfid SERIN
        ;
    pub BEEP
        #beeper APIN #2500 HZ 
        #100 ms MUTE
        ;
    pub BEEPS ( cnt -- )
        FOR BEEP #200 ms NEXT 
        ;     
    pub MAIN
        #2400 SERBAUD            \ Setuo baud rate for RFID reader
    \    ' RFID ukey W!            \ assign input vector used to input serial stream (comment out to test from console input)
        2 BEEPS                \ Let's just beep because we can to say we're ready
        DECIMAL
        BEGIN 
          GETWORD NUMBER        \ Read a word from the input and convert to a number ( number digits )
          IF 
            #enroll PIN@        \ Read the state of the enroll mode port pin 
              IF EDIT SAVE ELSE ENROLLED? THEN 
            DUP IF BEEP ELSE 3 BEEPS THEN        \ Single beep to indicate success otherwise beep beep beep
            RELAY 1 second OFF RELAY        \ If a true flag has been returned then this will turn on the relay for 1 second
          THEN        
        AGAIN
        ;
    \ Instruct Tachyon to run MAIN automatically on startup and backup the program and settings into EEPROM
    \ AUTORUN MAIN  BACKUP
    END[/FONT][FONT=courier new]
    [/FONT]
    

    EDIT: I have just tested this out using the normal console serial input and outputting the beep and relay to the demo board's LEDs. Works like a charm. Uncomment the 2nd line of MAIN if you want to do the final test with a RFID reader.
  • D.PD.P Posts: 790
    edited 2012-10-10 23:19
    SRLM wrote: »
    Can you post your code as an attachment?

    Are you running Tachyon SRLM? Inquiring minds want to know. Would be nice to see you join the FORTH wrecking crew.

    dp
  • SRLMSRLM Posts: 5,045
    edited 2012-10-11 03:17
    No, I was offering to help with the original code (which seemed likely to be Spin).
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-10-11 05:38
    172heavy, please post your Spin code and I'm sure we can figure out what the problem is.
  • 172heavy172heavy Posts: 55
    edited 2012-10-11 07:15
    Dave Hein wrote: »
    172heavy, please post your Spin code and I'm sure we can figure out what the problem is.

    Dave,

    I will post the code as soon as I get it organized, I am not a programmer so I tend to use alot of the demos and modify them for my projects. Currently I have been testing this in a very unorganized way and I would be embarrased to post what I have.

    Thanks for the Offer.
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-10-11 08:11
    Don't worry about posting hacked up code. Adding hacks to working code is one of the best ways to learn. I do that all the time at work when I try to figure out what the original developing was trying to do with his "self-documenting" code.
  • 172heavy172heavy Posts: 55
    edited 2012-10-11 14:51
    Here is the portion of the code that I have a quesiton about. I have a method to enroll the cards, however the data is only stored the RAM, how do I copy the data to the EEPROM? I would like to enroll to the array in the ram then copy all of the values at once to the eeprom. Upon boot up if the system is turned off I will need to copy the list from the eeprom back to the RAM. I am assuming accessing the data--while scanning in and out--will be faster than trying to read from the EEPROM each time.


    CON
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
       
      card_array_size = 10
    
    OBJ
       
      pst : "Parallax Serial Terminal"
      Mem : "Memory_Store" 
      
     
    VAR
    
     'long RFIDCODE [10]
     WORD INDEX
     WORD INDEX1
     LONG COMMAND
     WORD NBR
     long test123
     long RFIDCODE [card_array_size]
     
     
    PUB TwoWayCom | value
    
      pst.Start(115_200)
      pst.Clear
      mem.init
    
      {RFIDCODE[0] := RFIDCODE_ARRAY[0]    This was a test of some values. 
      RFIDCODE[1] := RFIDCODE_ARRAY[1]
      RFIDCODE[2] := RFIDCODE_ARRAY[2]
      RFIDCODE[3] := RFIDCODE_ARRAY[3]
      RFIDCODE[4] := RFIDCODE_ARRAY[4]
      RFIDCODE[5] := RFIDCODE_ARRAY[5]
      RFIDCODE[6] := RFIDCODE_ARRAY[6]
      RFIDCODE[7] := RFIDCODE_ARRAY[7]
      RFIDCODE[8] := RFIDCODE_ARRAY[8]
      RFIDCODE[9] := RFIDCODE_ARRAY[9]} 
    
                                         
      
      repeat 
    
         pst.Str(String("Enter a decimal value: "))  'this section is for my commands to manage the app.
         VALUE := pst.decin                          'Entering 45 displays the status of the array slots
         IF value == 45                              '46 starts the enroll process for now it type the 
           SLOTCHK                                   'values in on the PST term instead of scanning
         If value == 46
           enroll
         
         
         REPEAT INDEX FROM 9 TO 0                              'this section compares the scan with the array
            IF VALUE == RFIDCODE[INDEX]                        'eventually it will activate the relay when i get that far...
              pst.Str(String(pst#NL, "rfid FOUND-->"))
              PST.DEC(RFIDCODE[INDEX])
              INDEX := 0
              
            {ELSE
              pst.Str(String(pst#NL, "NO VALUE FOUND-->"))
              PST.DEC(RFIDCODE[INDEX])
              PST.NEWLINE
              PST.DEC(INDEX)} 
                     
              
         repeat 2
            pst.NewLine     
    
    PUB SLOTCHK
    
      REPEAT NBR FROM 0 TO 9
         IF RFIDCODE[nbr] == 0
           PST.STR(STRING(PST#NL,"SLOT # "))
           PST.DEC(nbr)
           PST.STR(STRING(" EMPTY"))
         ELSE
           PST.STR(STRING(PST#NL,"SLOT # "))
           PST.DEC(NBR)
           PST.STR(STRING("**FULL**-->"))
           PST.DEC(RFIDCODE[NBR])
           
           
    
    PUB enroll | start, limit ,valu
    
      pst.Str(String("Enter Slot Start: "))
      start := pst.DecIn
      pst.Str(String("Enter Number to Enroll "))
      limit := pst.DecIn
    
      REPEAT INDEX1 FROM start TO limit
         pst.Str(String("Scan Card: "))
         valu := pst.DecIn
         RFIDCODE[INDEX1] := Valu
         pst.Str(String(pst#NL, "RFID:--> "))
         pst.Dec(INDEX1)
         pst.newline
    
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-10-12 05:57
    172heavy, I looked at your code last night, and I didn't see any problems with the decin method limiting to 16 bits. I looked at in again this morning, and then I realized that you had edited your original post to say that you had fixed the problem. So that's one problem resolved.

    I'm not familiar with the Memory_Store object, so I can't really comment on how that works. I usually use the basic_i2c_driver object to do what you want to do. What I would do is create an array of your stored values in a DAT section, and then overwrite their locations in the EPROM image to save them. This way you don't even have to explicitly read them from EEPROM. The values will just be there when you boot from EEPROM.
  • 172heavy172heavy Posts: 55
    edited 2012-10-12 13:32
    Dave Hein wrote: »
    172heavy, I looked at your code last night, and I didn't see any problems with the decin method limiting to 16 bits. I looked at in again this morning, and then I realized that you had edited your original post to say that you had fixed the problem. So that's one problem resolved.

    I'm not familiar with the Memory_Store object, so I can't really comment on how that works. I usually use the basic_i2c_driver object to do what you want to do. What I would do is create an array of your stored values in a DAT section, and then overwrite their locations in the EPROM image to save them. This way you don't even have to explicitly read them from EEPROM. The values will just be there when you boot from EEPROM.


    Thanks Dave, I'll have a look at the basic_i2c_driver object and see if I can make it work. I appreicate the help!

    Have a great weekend.

    Josh
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-10-12 15:20
    You can easily load Tachyon onto your board and try out that code I posted. It does it all including backing up to EEPROM and also has a card edit mode which enrols or removes cards if they are already in the table.
  • 172heavy172heavy Posts: 55
    edited 2012-10-13 12:08
    You can easily load Tachyon onto your board and try out that code I posted. It does it all including backing up to EEPROM and also has a card edit mode which enrols or removes cards if they are already in the table.

    I actually plan on loading the code that you posted. I am interested in learning about Forth. I wanted to figure out the issues I had with spin first. A lot of what I do is to satisfy my hunger for knowledge and to learn about different technology etc.
  • 172heavy172heavy Posts: 55
    edited 2012-10-13 12:12
    I did like your idea of accessing the menu feature with key RFID tags. I used it in my code. Thanks for the tip.
Sign In or Register to comment.