Shop OBEX P1 Docs P2 Docs Learn Events
Edited Title - Homework board power? see last entry — Parallax Forums

Edited Title - Homework board power? see last entry

qxoticqxotic Posts: 47
edited 2009-09-16 19:14 in BASIC Stamp
I am looking for ideas. My project is to use a Basic Stamp to run a program to accept input from a keypad via an EDE1144 encoder. It then compares the input to a passcode list. Then either grants access or denies and records an event log.

I have a BS2 homework board I have been getting the program started on. I am to the point where it accepts the 4 digit code and compares to the list with no troubles. I just ordered the Sparkfun RTC breakout board for getting the time needed for the log. I am confident the log file will not be greater than 500KB if I let it run for 6 months without clearing it. Given this as a parameter, is the USB memory stick data logger the best option for storing the log file?

I want to be able to update the program/codes and get the log using a laptop via USB.

Which BS2p should I order? (I assume I will need a "p" BS2 due to the RTC using the I2C protocol)

What board should I get to be able to install the RTC, memory or data logger onto? Should I use one of the boards from parallax with the programming interface already built in or build one of my own?

Thank you,


Danner

Post Edited (qxotic) : 9/4/2009 2:12:12 PM GMT
«1

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-05 15:43
    There is code in one of the Nuts and Volts Columns on doing I2C with Stamps that don't have the built-in statements. You could even use your Homework Board with the Sparkfun board.

    Options for logging:

    1) Use Parallax's Memory Stick Datalogger. The data can be logged to one or more PC compatible files ready to process with your laptop

    2) Use a couple of AT24LC1024B EEPROMs (4 to be precise) attached to the same I/O pins as the RTC. That'll give you 512K bytes of EEPROM.
    ... You'll have to write a program (or part of your existing program) to send the log data to your PC via the programming port.

    3) Use a Winbond flash memory. These are available in PDIP form in sizes up to 2MB. Like the EEPROM, you'll need a program to download
    ... the data to your PC. Also, there are no examples for the Stamp that I know of. You'll have to write your own I/O routines. It shouldn't be hard.

    Consider the Super Carrier Board. It's laid out pretty much the same as the Board of Education, but for permanent wiring. I've used it for several
    permanent projects and it's worked well.
  • qxoticqxotic Posts: 47
    edited 2009-08-12 19:10
    Thank you Mike Green. I have connected the Sparkfun clock to my homework board. I have made good progress reading from and writing to it. The problem I have run into is I am out of memory space for variables. The part of my program that lets me update the time and date from my keypad takes it all up. I have them all declared at the beginning of the program. I read through the help section of the Stamp Editor program but did not see anything about removing something from memory when you are finished with it.

    I was thinking of using the extra memory on the Sparfun to store the program for updating the time and date but have not discovered yet how to put it there or call it up when needed.

    My main hurdle right now is running out of memory with my variables. What is the best way to address this problem?


    Thank you,

    Daniel
  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-12 22:39
    It's very rare for a program to need all of the variables all of the time. Very often, temporary variables are used during a subroutine call, then not used until the next call to the same subroutine. These can be shared so that maybe they're used in a different subroutine under a different name. Look in the Stamp Manual index under "aliases" or "alias". This is a way to declare a new name for the same variable space.

    It's not practical to store part of a program in some kind of external storage since it has to be moved to EEPROM for execution and that's a very slow process. Programs can often be trimmed down by shortening or removing DEBUG statements and shortening strings used in SEROUT or other output statements. Often there are subroutines that are nearly identical that can be combined. Sometimes using a different technique (like table lookup) can simplify a complex program and trim it down in size.
  • JDJD Posts: 570
    edited 2009-08-12 22:40
    qxotic,

    A common practice, is to see if you can reuse, or create constants out of variables. Do you have any chance of that? Can you post your program that you currently have so we can take a look at it? If you use the Attachment Manager, we can look at your program in the BASIC Stamp Editor; which makes working with code easier than cut and paste.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Respectfully,


    Joshua Donelson
    www.parallax.com
  • qxoticqxotic Posts: 47
    edited 2009-08-13 14:39
    Thank you for the replies,

    I think I have attached the file which is part of my program. This part lets me enter the update of time and date from my keypad and updates the sparkfun clock.

    A few ideas that may save space I had are:
    1. would it help to make the Beep routine a sub? At different times in the program I want a different number of beeps.

    2. secs, control, and day (of week) are data I do not track in my program so they can be reused, I would just have to correct/update them before any update to the clock.

    I did read about alias yesterday. Is is possible to alias an array? For instance if you had a Nib(15) variable and later wanted to reuse it as a smaller array?

    most of this part of my program are taken from different postings I found in the nuts and volts. I am testing this on my BS2 Homework board. I will next be adding the usb data recorder. If I was using a BS2p which could use the I2C protocol instead of the workaround, would it save me much in regards to variables needed?

    Thank you,

    Daniel
  • qxoticqxotic Posts: 47
    edited 2009-08-18 16:18
    Update:

    I have attached my work to date which is now consolidated to this one file.

    I only have 3 blocks left on the RAM right now. I have ordered the USB datalogger which will be added to store the file from the History sub.

    I am very new at this, so please take a look at what I have so far and let me know where I can improve it.

    Much of the code was cut and pasted from posted projects and then edited for this project. Some of the coding I copied is not real clear to me. There is/was coding for a variable of "wrdAddr" I am not sure what it was used for.

    Next question: there is a second number after the code in the DATA area. I tried doing away with it but could not get the coding right for it to work.

    Next question: In the keypad loop, where it waits for a key to be entered from the keypad, I would like to add a timeout to it so that if someone pushes a button and walks away, that digit is not hanging in there and messing up the next person. How do I put a timer in that loop to clear and start over after so much time of no activity?

    Is there a good example of how to access the USB datalogger?

    Thank you for the input.

    Daniel
  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-18 16:30
    1) There's no timer on the Stamp that you could use for a timeout, but you can easily count the number of times your program goes through the loop waiting for a key to be entered. If that count gets bigger than some limit you set, the program exits from the loop with a "dummy" key value that indicates a timeout and the rest of the program tests for that value and reacts appropriately.

    2) As with most Parallax products, the product page in the webstore has links to documentation and sample programs. Look at the USB datalogger's webstore page for these.
  • qxoticqxotic Posts: 47
    edited 2009-08-18 18:30
    Thanks Mike, that was a lot easier to find than searching through the forum posts. That does leave me with an even bigger RAM problem. The buffer needing a 15 Byte array is a big problem. The items I have at the end I am not able to store in other variables and add enough onto my array before I run out of RAM. What are the workarounds?

    Is it possible to write my time, date, code, note etc.. to DATA and then pull them from there, thereby freeing up their variables?

    I have ordered the BS2pe, the super carrier board and the datalogger.

    Thank you,

    Daniel
  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-18 18:36
    The BS2pe has additional memory in the form of scratchpad ram. This is accessed using the GET and PUT statements and, to a limited extent, with the SERIN and other I/O input statements (SPSTR formatter). That would be preferable to using EEPROM.
  • qxoticqxotic Posts: 47
    edited 2009-08-18 19:07
    I guess I am still not clear on the solution. I read the SERIN, especially the Special formatter SPSTR section in the PBASIC syntax quide (the help that comes up from the BASIC program.) It still seems that putting it there will require the same number of variables to be used? Is that correct? Running out of available variables is my problem more than having a place to keep the data in them. So far my EEPROM MAP is fine, but my RAM MAP has only 3 bytes left so I don't see how I can add what I need for the data logger?

    My program would only be writing to the memory stick, not reading from it. Does this help me? The buffer which takes up so many bytes in the array, can it be replaced with a FOR LOOP or something similar? What is in these bytes and do I need them? Much of the program example I see is using the array to purge the buffer. Can my data be sent without using a 15 Byte Array for buffer?

    Thank you again,

    Daniel
  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-18 19:53
    The buffer is needed to read status information (then ignore it) from the datalogger. You could use the scratchpad ram for this buffer.

    There are probably some variables that could get moved into scratchpad ram while the same space is used by the datalogger routines.
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-08-19 18:49
    Hi Daniel, an alternative would be to use the method described in this thread http://forums.parallax.com/showthread.php?p=807516

    and to configure the Datalogger frimware as described in this thread http://forums.parallax.com/showthread.php?p=821241

    The latter thread enables you to do away with the configuration code for the logger and also "boots" quicker

    The first thread·, using a fixed string as a file name , requires only your existing "history" variables ,·no additional variables are needed.

    Jeff T.
  • qxoticqxotic Posts: 47
    edited 2009-08-20 18:41
    Hi Jeff,

    Thank you for the links. I had found the one previously. I've read through them a couple of times now still trying to figure it out. I do have a few questions.

    Are you using it in UART or SPI? EDITED - from reading the Firmware VDAP pdf I concluded it is UART since only that mode can be changed in the flash file.

    Your text folder has a different wiring method than any I see on the datalogger sheet from Parallax. Why the difference?

    I read on the Vinculum site, it said to use 47 KOhm, (not 4.7K) as the pull up Resistors, the Parallax sheet does not show any. (since this site only talks about their chip, is that something already built into the datalogger?)

    I read the forum on reconfiguring the boot up of the drive, still pretty foggy on that. It sounds very useful for simplifying things. How complicated is it to do?

    THe baud rate, you mentioned for the BS2 that 9600 did not work well. Would you suggest going down to 4800 on the BS2pe also, as well as the SCS? (shortened command set)

    The links mention power cycling.. and using a pin for cycle power? I get the impression when a power outage occurs, without doing something special, the datalogger would not come back online?

    My parts are coming snail mail so I have some time to think before I get to experiment.

    Thank you,

    Daniel

    Post Edited (qxotic) : 8/20/2009 7:45:25 PM GMT
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-08-21 02:41
    Hi Daniel , in answer to your questions

    1/ You are right it is UART

    2/ The Parallax documents that support the Datalogger revolve around the use of hard wired serial communication flow control·. This requires a 4 wire connection to the····· Stamp , TX , RX , CTS and RTS. The method that I described·relies in the main on the prompt character returned from the Datalogger as flow control and only requires TX·, RX with CTS connected to Vss·.

    3/ I have used the logger·and no·resistors without problems.

    4/ Reconfiguring the·firmware is very easy and really is worthwhile for several reasons. Ask for more details when you are ready.

    5/ Synchronization between the Datalogger and the Stamp relies on the prompt ( > ) , the PBasic instruction is SERIN ,rx,baud,[noparse][[/noparse]WAIT ">"]·. This instruction is not always reliable at speeds greater than 4800. The slower baud rate is compensated for by the lack of the additional overhead in code and a more direct and simplified set of instructions. Not sure about the pe probably needs 4800 also but I know the px will run at 9600.

    6/ The logger is very particular about the commands it receives and even a small error can "lock" things up. The only escape from this situation is a reset/powerdown of the logger , ( a part of reconfiguration makes it easier to recover ) . Don't worry about power cycling initially.

    Whatever you decide to do when you receive your parts , CTS/RTS or prompt ">" just post back with anything you are unsure about , there are plenty here to help.

    Jeff T.
  • qxoticqxotic Posts: 47
    edited 2009-08-21 13:58
    Thanks Jeff and Mike for clearing up a LOT of unknowns for me.

    It will be next Wednesday before I have time to pick the project back up, (if the parts come in by then).

    Jeff, I am following most of what you answered. I think to be safe I will set the baud at 4800 on mine.

    In my case the datalogger is not needed very often. The stamp is always scanning the keypad, but only when there is an entry does it process anything to send to the logger. Is is possible, or advisable, to only power it up when needed? If so, how would you suggest it be connected?

    I'll check back Wednesday.

    Thank you all again and have a great weekend.

    Daniel
  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-21 14:27
    It's possible to power the datalogger through a PNP switching transistor and turn it on only when needed. Unfortunately, the datalogger takes quite a while to initialize itself and that may be prohibitive for your application.
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-08-21 16:44
    Hi Daniel,

    Write-only to the USB datalogger can be done with very economical code. The datalogger does not always return back a ">" prompt, but that only occurs when there is some error condition such as no disk present or file name error or disk full. Your code will probably cover all errors with a timeout, or by sending another CR to the data logger to recoup the ">" prompt. For that reason, there is no need for the 15 byte buffer and simply waiting for the ">" (with timeout) will suffice.

    I appreciate Jeff's approach that reduces the number of wires required, but if you do have a pin available on your Stamp, the flow control does work very well for the most part. If you are going to use the flow lines, the one that the Stamp can use to tell the datalogger to hold off on sending data is the most important. In the other direction it is not so important as it is unlikely that you will send data fast enough from the Stamp to overrun the datalogger serial buffer. If you use the flow control, you will not have to mess with custom firmware patches, I think, and it will work fine at the default 9600 baud.

    Is your application battery powered or tight on power requirements? The datalogger with a USB stick installed will draw about 100 mA. There are two commands for reducing power. SUD (suspend disk) reduces the draw to about 25 mA, and SUM (suspend monitor) reduces it to about 2 mA. The time to power back up is pretty quick. Nevertheless, I always include means to power off the datalogger completely, because I'm trying to run on micro-power from batteries, and also because it provides a failsafe means to recover from things that go bump in the night in unattended remote location. Like Mike pointed out, it does require several seconds for the datalogger to initialize.

    Be sure your datalogger has the latest firmware. The initialization speed is improving, as is the compatibility with different USB sticks. The firmware is available from the Vinculum.com web site. It has to be put into the root directory on a USB stick and named "ftrfb.ftd", and then when the datalogger boots up it looks for that file and will automatically update the firmware.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • SRLMSRLM Posts: 5,045
    edited 2009-08-21 22:16
    @Tracy

    I'm glad you mentioned the firmware updates, since I'm having trouble with it over in the Propeller forum. Is the correct update found on this page under the title of "VDAP Disk And Peripheral Firmware" download "Reflash FTD"? I put it on the stick (with your recommended filename) and it seemed to do alot of USB drive blinking. I'll have to retest my code that I'm having problems with to see if that helps the problem. Thanks for your post.
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-08-22 01:19
    That's right, be sure you get the reflash (.FTD) not the bootloader (.ROM). The current version as of 21-Aug-2009 is 3.68. It does take several seconds for it to detect the new version, and then to load it. If you watch the process on a terminal screen, the datalogger sends back a message that it has detected the new version and then it spits out a lot of periods as it loads the new version and finally it ends up at the ">" prompt. Everything will work out okay if your program is waiting for that ">" prompt to appear.

    By the way, the firmware can be downgraded as well as upgraded. It only looks for a ftrfb.ftd file that is different from the one that is currently installed, not necessarily newer. Beware if you leave old versions of the ftrfb.ftd file lurking on USB sticks at the back of a drawer.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • qxoticqxotic Posts: 47
    edited 2009-08-26 16:05
    Update:
    I got the data logger in. I reformated it using FAT32 and 512. First I connected it to the 4 pins and ran the DataloggerTestV1 program. That program worked fine and I was able to read the data from my computer.

    Then I wired it as Jeff mentioned in the Two-Wire-1 file and tried running the SimpleLog program. I remove the drive and hit one, then it detects and gets to the "Be patient......" line where it hangs. The red light on the datalogger stays on as well as the led on the drive itself. Is there a safe way to disconnect the drive when it hangs like this? I am guessing it is safe because it has not gotten to the point of opening a file and writing data yet.

    Did the firmware need to be udpated before I tried running this SimpleLog test?

    Any suggestions?

    Thank you,

    Daniel
  • qxoticqxotic Posts: 47
    edited 2009-08-26 16:13
    Tracy,

    I do have extra pins available. Which way connecting the logger will use the least number of variables?

    For testing I am using my homework board powered by a 9V battery. The finished product will have a computer power supply running it. The 3V line may sometimes drop too low so I was thinking of using the 12V for positive and the 5V line for negative.

    I have seen some code examples using the SUD and SUM commands. Since the logger will not be checked often, I want to do it whichever way is the most robust, or can recover from errors on its own. The several seconds to initialize may not be a problem.

    I will be sure to have the right firmware filename when I am ready to update it. Thank you.

    Thanks again,

    Daniel
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-08-26 17:13
    Hi Daniel , I believe your logger is initializing faster than the 3 second pause before the "Be Patient" line ( which is actually a good thing ) , remove the pause and retry.

    There is no need to mess with the firmware right now , the program should work as is.

    Jeff T.

    EDIT: thinking about that a little more it would probably be better to remove the three lines

    · PAUSE 3000
    · DEBUG "Be patient.........",CR
    · SERIN RX, Baud,[noparse][[/noparse]WAIT("No Up"),WAIT ("grade")]

    and replace with

    SERIN RX, Baud,[noparse][[/noparse]WAIT(">")]

    whichever works the better.

    Post Edited (Unsoundcode) : 8/26/2009 5:25:22 PM GMT
  • qxoticqxotic Posts: 47
    edited 2009-08-26 18:09
    Jeff,

    Thank you for your help.

    I tried a couple things, took out the 3 lines and replaced with the other one; noted out the pause; increased the pause to 5000 and tried it with each SERIN command. It still just hangs with the red light on the logger on solid and the light on the cruzer going from bright to dim and back.

    I don't know enough about it yet to take a guess as to why.

    Daniel
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-08-26 18:54
    Hi Daniel , thanks for trying and most important thanks for the feedback.

    I don't have an answer right now ,when you get to the Device Detected line the Logger only has to wait for the flash drive to finish looking for an upgrade. It seems not to be catching the acknowledgement .

    The last thing I would try is to remove the SERIN instruction before "Logger is Ready" completely and see if the program continues successfully.

    The baud rates 84 (9600)·and 188 (4800) are for BS2 , BS2e and BS2pe but it seems you have that covered.

    thanks again I'll check it out

    Jeff T.
  • qxoticqxotic Posts: 47
    edited 2009-08-26 19:15
    Hi Jeff,

    Taking that command out, it then asks for a filename... I enter 4 characters and it returns a message showing the four characters with a 1 on the end and "file not found..."

    Hope that helps.
    Daniel
  • qxoticqxotic Posts: 47
    edited 2009-08-27 18:43
    I have downloaded the program and file to update the FTD. The options I changed were from 9600 to 4800, ECS to SCS and No for showing the prompts and reports. It does still allow firmware upgrades.

    I have not loaded this yet, wanted to double check here first.

    The only change I was not sure of, should I change IPH to IPA? My data is shown on DEBUG as follows:
    DEBUG ? Apt(9), ? keycode, ? Note(11), ? TimeZone(1), CR
    DEBUG CR, HEX2 clock(3), ":", HEX2 clock(2), ":", HEX2 clock(1), CR ' clock(1) will not need to save to file
    DEBUG "20", HEX2 clock(7), "-", HEX2 clock(6), "-", HEX2 clock(5), CR

    I hope to be able to read the file from the drive when I connect it to the computer with the above variables showing as follows:
    10,1234,1,2,12,30,09,08,27

    How do I need to save it to be able to read it from the computer as on the above line?

    I still have not had any luck getting the logger to work with just 2 data lines, but seems to work fine with the 4.

    Thank you,
    Daniel
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-08-27 22:19
    Hi Daniel , provided you leave the option for upgrades you should be safe.

    I would tend to go for IPA initially.

    If you end up going with 4 wire (Tx,Rx,CTS and RTS) you might be ok at 9600.

    I·have a few thoughts·on·the two wire set up·I would like to PM to you later , I have used the exact same configuration with the BS2 , SX and recently the Propellor with success so I am interested with whats going on in your case. Having said that , if you can get everything to fit with the 4 wire code it might be better for you to use something you already have working.

    regards

    Jeff T.
  • qxoticqxotic Posts: 47
    edited 2009-08-28 14:00
    I have my super carrier board in and am deciding how to make my connections. It has a 20 pin connector titled X1. I searched the Parallax site for a connector and only came up with item code 450-02003 which says "20-pin header, used as an AppMod header. .44 mils, .29 pin" It also says "Great for through hole applications" Would this connector plug into the header on the Super Carrier Board?

    I am planning to use a computer's power supply to power the board. I do not have a round power connector. Would the board work as well if I connect a 12V line to the postive 9VDC connector and a 5V line to the negative of the 9VDC connector?

    Thank you,

    Daniel
  • qxoticqxotic Posts: 47
    edited 2009-09-04 14:09
    On the Homework board, can 12V be connected to the 9V terminals without causing problems?

    I was using the 12 and 3 volt lines for 9 from a computer power supply... but that won't work when I connect my keypad board to it because they share a ground.. which would cause the 3V line and the ground to have a common point.

    Thank you,

    Daniel
  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-04 14:19
    That (using 12V supply input) depends on the amount of current being drawn. The Homework Board's regulator doesn't have a significant heatsink and all the "extra" power (12V - 5V = 7V x <current drawn> = <HEAT!>) has to be dissipated as heat.
Sign In or Register to comment.