Shop OBEX P1 Docs P2 Docs Learn Events
Project: Feeder System — Parallax Forums

Project: Feeder System

Palli SteinaPalli Steina Posts: 6
edited 2009-07-20 18:02 in BASIC Stamp
Hello everyone.

I'm working on a project that sounds simple, but I feel like I'm doing a good job of complicating it.

We are making a feeder system that is suppose to feed fish at 100m depth at regular intervals. The plan is to have a BS2 control a solenoid valve and open it for a "X" period of time, close and wait for "Y" period of time, loop. The BS2 will be connected to a PC via RS232.

The problem:

I want to be able to change "X" and "Y" through the RS232, but I'm having hard time figuring out the best way. I dont want the BS2 to be dependant on the PC, so when the data is sent, it should feed at that interval.

How would I "listen" for a serial string sent from a PC while still looping the feeder?

Regards,
Palli

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-07-20 13:45
    Hi Palli , several ways of doing this . Maybe you could use the "Y" time of your loop as part of a SERIN command that waits for any update to the timing values . If there is no update the program just continues it's loop , if there is a signal to update then it would direct you to a sub routine that waits for your new timing values
    SERIN Rx,baud,Y_time,No_update,[noparse][[/noparse]WAIT("!")]
    DEBUG "Enter Y time..."
    SERIN Rx,baud,[noparse][[/noparse]DEC3 Y_time]
    DEBUG "Enter X time..."
    SERIN Rx,baud,[noparse][[/noparse]DEC3 X_time]
    No_update:
    ''Continue your LOOP here
    

    Typing in an exlamation signals you want to update and the debug statements prompt you to enter the new values .

    Jeff T.
  • Palli SteinaPalli Steina Posts: 6
    edited 2009-07-20 14:20
    Hello Jeff, thanks for your reply.

    Its good to have someone to point your way when you have been running in circles. This had crossed my mind, but the code I had already written was in the way.

    I'll finish this up and post my code when its done.

    Regards,
    Palli
  • Palli SteinaPalli Steina Posts: 6
    edited 2009-07-20 15:34
    Here is what I came up with:
    [code]

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    ' Fastar
    relay PIN 0 ' Relay
    timi CON 60000 ' 1 min

    ' Breytur
    bid VAR Word ' Lengd p
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-07-20 18:02
    Looks well laid out Palli .

    I would change the Debugs to SEROUT too. The previous was only pseudo type code for example which you seem to have adapted quite well.

    Only other thing I might do is run at 4800 baud or less , speed is not that critical , but if it's working leave it as it is

    Jeff T.
Sign In or Register to comment.