November 21, 2024, 11:36:31 PM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Prop 1 Serial program problem

Started by bsnut, December 28, 2007, 11:24:38 PM

Previous topic - Next topic

bsnut

Jon,

I have an project that I am working on for an trolley museum that uses two Prop 1s. I would like to have two Prop 1s talk serialy. I am having some trouble with the the program.

Thanks,
BSNUT
William Stefan
The Basic Stamp Nut

gadget-evilusions

You should post your program and describe in detail what you are trying to accomplish.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

If you post your programs I can help out.  Briefly, though, you'll want to use OT2400 serial between P7 of both boards.  The master will send a specific sequence and the slave will react to it.  The tricky bit can be protocol -- you have to make it up yourself.  What I suggest is that you use a fixed-length protocol, perhaps using a header to ensure sync of the actual command bytes.  Let's say you have a header of "!BSN" and that will be followed by two bytes.  On the master side you'd have something like:

  SEROUT Sio, OT2400, ("!BSN", cmd, subCmd)

At the top of the main loop in the slave you would have something like this:

  SERIN Sio, OT2400, ("!BSN"), cmd, subCmd

This will force the receiver to wait for the string "!BSN" before accepting the cmd and subCmd bytes.  You don't have to use the header, but it does prevent problems if your master tries to send a command to a slave that's not ready.  Remember that the BS1 cannot escape a SERIN instruction until it is satisfied, so you can't blink outputs or do other "moving" things while sitting on SERIN.

Again, if you tell me what the master and slave are suppose to do I can give you much more help.
Jon McPhalen
EFX-TEK Hollywood Office

bsnut

December 30, 2007, 01:48:34 AM #3 Last Edit: December 30, 2007, 01:54:12 AM by bsnut
Jon and Gadget-evilusions,

Sorry, I didn't post my program, that's because, I didn't bring it with me to the computer that was using. I'm also sorry that I, didn't describe in detail what I was trying to accomplish the frist time. 

The main goal is to get the Prop 1's to talk back and forth (Pear to Pear coms). The Prop 1's are being used as signal controllers, one at each end of the block on an trolley line. The Prop 1's are counting when the trolley pole passes trough a two part trolley contactor mounted on the wire, and passes the count and direction(counting in) information to other controller serialy(within six inches) to the other Prop 1 which sets the signal, and when the trolley pole passes trough contactor mounted at the other end of the block and passes the count and direction(counting out) information serialy back to other controller and resets the signals.

I will post the program that I have the next time.

Thank you for your help,
BSNUT
William Stefan
The Basic Stamp Nut

bsnut

Jon,

Here, I attached my program for the signal controller. This signal controller is known as an "Nachod", which counts the trolley cars in and out of the protected single track section. This consits of two controllers, one for each end of the protected single track block. When the North Signal Controller counts up (counts in), this controller lights and flashes the white signal on this controller and then tells South Signal Controller to light the red signal on its controller and then waits for the car to count down (counts out) at the South Signal Controller or sees if the car backed out at the North Signal Controller. If the car leaves at the other end, the South Signal Controller tells the North Signal Controller to count down (counts out). If one car counts in at the North Signal Controller and then counts out at the South Signal Controller the signals on both controllers will turn off and resets the count to zero. The same amount of cars that count in, must count out in order to reset the signals to the all off(dark). If two cars count in at the North Signal Controller and two cars backs out at the same controller it will count down (count out) to zero and turn off(dark) all the signals. The North Signal Controller and the South Signal Controller are running the same program.

Thank you for your time,
BSNUT
William Stefan
The Basic Stamp Nut

JonnyMac

Hmmm.... not being the sharpest tool in the shed, this isn't really sinking in.  You seem to want to do something asynchronously, yet are constrained by SERIN on the BS1.  Remember, you have to be sitting on SERIN to receive data -- there is no hardware UART and no buffering.  If you're not on SERIN when data comes, that data is lost.

Notes/Comments

1. Your program doesn't compile because you're using Sio instead of the actual definitions: SioRX and SioTX

2. You will need to modify the ULN for your RX and TX pins
    -- see this thread:

3. There is no need to use the EEPROM for temporary storage with this program; in fact, it's really not a good idea to use EEPROM as general memory.

4. Is there a pressing reason to use two controllers?

5. How do you know a car is entering versus backing out -- isn't this tripping the same sensor?  Or are you looking to see that it clears the entry sensor and then hits the exit sensor before counting it as in?  If this is the case you can use a state machine to simplify the code.

I'm reformatting the program to my standards so that I can get a grip on it.  I think you need a north/south selector because the north unit gets a car first, then sends the message to the south.  The problem becomes this: the north must be sitting on a SERIN waiting for the south count or else it will be missed.  When doing this, it can't look for other cars.
Jon McPhalen
EFX-TEK Hollywood Office

bsnut

Jon,

Sorry I did not reply sooner. I see what you are talking about SERIN on the BS1. I know that the BS2 is the best way to go, which I wrote a program for.

Thank you for trying to work this out. The reason for two controllers, was to try copy the "Nachod" signal system using serial Com's, since the controllers of the 1920s used pulses to tell other controller at other end of the single track block when a car was counting in, counting out or backing out.   

Your question "How do you know a car is entering versus backing out -- isn't this tripping the same sensor?" No, it not the same sensor, when the trolley pole on the car passes trough a two part trolley contactor(which has two inputs wired to it) which is mounted on the wire, this is able to tell the controller when the car is counting in, counting out or backing out and then tells other controller at other end of the single track block when a car counted in, counted out or backed out .

How many times can I, write the EEPROM when using it for temporary storage for any program?

This should answer your questions and thank you again.

Bsnut
William Stefan
The Basic Stamp Nut

JonnyMac

February 24, 2008, 08:46:33 AM #7 Last Edit: February 24, 2008, 09:22:01 AM by JonnyMac
The EEPROM is guaranteed for a 100,000 cycles.  That said, if you make a programming error that gets you into a loop that constantly writes to a location you could burn it up.  Don't do it -- you have loads of RAM left in your program so there's no reason.

Looking at the program again, I don't think you can pull this off with the Prop-1.  The reason is that the Prop-1 cannot timeout a SERIN statement, hence it could be waiting for serial data that may not come when a train arrives.  If you only have contacts and lights you could arrange the I/O like this:

PIN7 : North contact A
PIN6 : North contact B
PIN5 : North Red
PIN4 : North Yellow
PIN3 : South contact A
PIN2 : South contact B
PIN2 : South Red
PIN0 : South Yellow
Jon McPhalen
EFX-TEK Hollywood Office