BS2px to BS2px Serial Comm problem
Falcon
Posts: 191
Hello all,
For a while I have had a BS2px and a BS2 communicating flawlessly using the following Serial code:
BS2px (Base Unit)
BS2 (Remote Unit)
To gain some code space for additional functions, I replaced the BS2 (Remote Unit) with another BS2px. I then replaced the baud code with the same as used for the Base Unit BS2px code. Those were the only hardware and software changes made at that time. Now I cannot get the two px's to communicate.
Since both Stamps are the same flavor, shouldn't the baud code be the same as well?
Would the best solution be to add the following from the BSS&RM:
I may have to break down and buy that Serial Port Complete book by Jan Axelson (it's been in my Amazon cart for a month now), but I'm hoping there is a simpler solution in the mean time.
falcon
For a while I have had a BS2px and a BS2 communicating flawlessly using the following Serial code:
BS2px (Base Unit)
T9600 CON 396 Inverted CON $4000 Open CON $8000 Baud CON T9600 + Inverted SERIN SI\FC, baud, 100, notalk,[WAIT ("Report"), current1, current2, a2dResult0, a2dResult1, a2dResult2, a2dResult3] ' Serial In from Remote BS2
BS2 (Remote Unit)
T9600 CON 84 Inverted CON $4000 Open CON $8000 Baud CON T9600 + Inverted SEROUT SO\FC, Baud, 2, Main, ["Report", current1, current2, a2dResult0, a2dResult1, a2dResult2, a2dResult3] ' send the data
To gain some code space for additional functions, I replaced the BS2 (Remote Unit) with another BS2px. I then replaced the baud code with the same as used for the Base Unit BS2px code. Those were the only hardware and software changes made at that time. Now I cannot get the two px's to communicate.
Since both Stamps are the same flavor, shouldn't the baud code be the same as well?
Would the best solution be to add the following from the BSS&RM:
#SELECT $STAMP #CASE BS2, BS2E, BS2PE T1200 CON 813 T2400 CON 396 T9600 CON 84 T19K2 CON 32 T38K4 CON 6 #CASE BS2SX, BS2P T1200 CON 2063 T2400 CON 1021 T9600 CON 240 T19K2 CON 110 T38K4 CON 45 #CASE BS2PX T1200 CON 3313 T2400 CON 1646 T9600 CON 396 T19K2 CON 188 T38K4 CON 84 #ENDSELECT Inverted CON $4000 Open CON $8000 Baud CON T38K4 + Inverted
I may have to break down and buy that Serial Port Complete book by Jan Axelson (it's been in my Amazon cart for a month now), but I'm hoping there is a simpler solution in the mean time.
falcon
Comments
Let me chew on your code a little, i'll get back to you soon.
Paul
I know it is the same set-up but double check this anyway:
Make sure your ground between the two stamps is in good shape. I like to twist the Serial Data Line with a Ground (about 2 twists per inch) so the AC (edges) of the signal has a good return path (AC takes the path of least inductance).
Try this: see it you can hack up some code to do serial in and out between some pins on the same stamp. In the mean time, I am still looking at your code.
Paul
By all means, you code should always have the conditional compile code for the baud modes - they are constants and pre-processor (#) commands so they don't take up any space in your target EEPROM.
You only sent a code fragment... so I coded using IO PINs 1 and 2. Are you using IO 16 (the dedicated Serial pin) for Tpin, Rpin or both?
I am trying to watch the football game and my wife keeps asking me if I see Sallie (one of the Patriots Cheerleaders is our friend). I will see if I can try your code on on BS2px after the game.
So far what you are doing seems to be routine. Are you getting garbled data, or no data timeout? Try putting in a label for the Parity error, I always use them.
Paul
I'm using pins 7 & 8.
I just re-installed the BS2 (with the previous code) and the BS2px communicates with it just fine.
I can't think of a reason that the px to px communication wouldn't work with both units using the same baudrate codes.
I'll make anothe attempt with the conditional compile code inserted in the Base and Remote units.
I appreciate your assistance,
falcon
I agree, this should work. Let me see if I can find an old BS2px (I think I have one somewhere that works but I blew out a couple of IO on it) Tip: Never get rid of a PStamp, you can always fix them for a fraction of the price or reuse them if only a few IO are blown.
Patriots won last night, we didn't see Sallie.
I'll get back to you later.
Paul
Also, on your new BS2px, try using different IO and if that makes any difference.
Try using a larger timeout in your SERIN command. This may sound counter-intuitive, but until you get this working use longer timeouts.
As you know the, remote unit's code will run faster (and a lot of its timing constants are different) now that you are using a BS2px.
I only found 1 BS2px. I had mentioned to loop back the IO on the PS2px but I forgot to mention you need to externally delay the signal (SERIN and SEROUT cant run at the same time in a BS2 series device). I have an FPGA development board that used when I did this years ago (I made a 200ms digital delay from it which worked in my application)... so don't even try that experiment - you have two BS2px's anyway and that is eaisier with which to experiment.
Keep going, I'm still looking at it on my end.
Paul
I pared the code down to just the essentials to see if I could get just 2 bytes to send/receive between the 2 BS2px's. Coincidentally, I did increase that SERIN timeout to 200. See following code:
Base unit code
I reinstalled the BS2px in the Remote unit and installed the following pared-down code:
Still no luck reading those 2 Bytes on the Base Unit. The DEBUG code on the Remote Unit does display the 2 Bytes in 8-bit binary so that leads me to believe that the BS2px I'm using in the Remote Unit is working. However it doesn't confirm the two I/O pins I'm using on that 'px are good. I suppose that's my next step.
The Base and Remote Units are in my house and garage, but it's a pain to walk back and forth to check to see if its working. I have extra BOE's so I may have to mock it all up on one table to speed up the troubleshooting process.
Also, I do have a BS2pe so I guess I could try that in the Remote Unit.
I look forward to any suggestions you or anyone else has.
falcon
Yes, trying different I/O pins would be the next logical step. I think I mentioned that before, but anayway....
I was thinking the same thing as your code shows. Attached is the code that I tried on my BS2px. I looked at the signals on a scope and the Remote BS2px was putting out the proper data. I only have the one BS2px so I had to use a Arbitrary Wafeform Generator to take the place of the Remote BS2px. I emulated the data stream and pumped it back into my BS2px (now programmed as the Base) and it received it all pefrectly.
Things to try (just for experiments):
Slower Baud rates
Dont use Flow Control
A different Pair of Pins on the Remote unit
A good ground between the two PStamps
Twisted Pair Signal/Gound for the Serial Data line
Another BS2px
Paul
Can you send me a photo of your setup? Use a private message if you like.
Also, how long is your serial line between the stamps?
Paul
I re-confirmed that the data transfers fine with a BS2 in the Remote location. BS2 to BS2px works good.
I then installed the BS2px from the Remote Unit into the Base Unit while leaving the BS2 in the Remote Unit. No data transfer. I suspect the BS2px I had been using in the Remote Unit has a problem.
I installed a BS2pe in the Remote Unit and installed the original BS2px into the Base Unit. Success. The 'pe will transfer the data to the 'px.
I will plug the suspected bad 'px into my PDB and check each I/O.
I am using every pin at the Remote Unit so switching I/O pins around to avoid a bad pin is not an option. In fact, if I had a good solution for using a BS2p40 at that location I'd have one there by now. Where do you get a carrier-type board that will accomodate the 'p40?
Thanks for all of your assistance. Sometimes you just have to work through a problem with someone else to provide some other troubleshooting angles and an entirely different set of experiences.
falcon
Fantastic! Yes, when I was a young pup Engineering Assistant, the engineers would always ask me if they could explain their designs to me. As they described what they were doing, they often found little bugs here and there - all I had to do is listen and ask a few questions... everybody learns in these situations. That is what this Forum is like somtimes - a peer review.
I will check Digikey and see what they have. I think Parallax may have some boards too. I will get back to you with some links.
Hey, by the way... is this project some kind of battery charger or block heater monitor for your cars?
Paul
1)
This is a low cost solderless breadboard that I have used before and it is inexpensive (about $8).
http://search.digikey.com/us/en/products/TW-E40-510/438-1109-ND/2618532
If you have a Parallax BOE or Homework Board you can carefully remove the small proto board that comes with it (it is held on with double stick tape). Then you can stick this one in its place. It will hang over the Board, but it will work.
2)
The Super Carrier Board is good but the prototype area is 2 rows too shy for the BS2p40! ($20)
Parallax did that to get you to shell out $160 for the Professional Board. But, you may be able to cut some traces to get a BS2p40 to work on it.
http://www.parallax.com/Store/Microcontrollers/BASICStampDevelopmentBoards/tabid/137/CategoryID/12/List/0/SortField/0/Level/a/ProductID/122/Default.aspx
I was thinking about getting a Super Carrier Board and then installing a Zero Insertion Force (ZIP) connector. ($15)
This way I could swap in and out BS1's, BS2's, BS2p40's as needed - with a flip of a lever (no more bent pins pulling out a PStamp!).
http://search.digikey.com/us/en/products/40-6554-10/A306-ND/27600
3)
Parallax has their Professional Development Board (if you want to shell out $160)
I has a lot of nice features but I have access to all of them in the lab so I never purchased one.
http://www.parallax.com/Store/Microcontrollers/BASICStampDevelopmentBoards/tabid/137/CategoryID/12/List/0/SortField/0/Level/a/ProductID/123/Default.aspx
Paul
The project is a home monitoring system, and is still in development. About 60% complete now. I'm monitoring door locks, garage door positions, window positions, weather alerts, driveway sensors, CO and Smoke, washing machine and water heater leaks, cold and hot water temps, various inside and outside air temps. I can monitor it all on my mobile phone too. I am expanding to include an RFID reader and electric door bolt and a datalogger to keep a history of all events. I'm also trying to incorporate as many provisions for future functions as possible before I have my PCBs made.
It's all really for fun and a learning experience. None of it is absolutely necessary since I've lived 47 years without any of it.
falcon
Paul,
Thanks for the links and all the time and effort helping me out.
#1 is a good idea. I already have several of those BBs so that is a real possibility. My Home Monitor project will be based on two BOEs with additional circuitry placed on a second PCB connected with header cables.
#2 That ZIF is a good idea but I can see where $10 would be a lot to add to production costs. I have a BS2 with pins that look like a squashed cockroach.
#3 I have a PDB but it is overkill to install in a project. I have/will install a BOE, but that's a lot less. I did happen to bid on and win a little board at the last Parallax EBay dump that allows me to install a BS2p40 and then plug it into a 28-pin socket. It has an extra hsingle header row that allows connections to the AUX I/O's.
I was too late to get one of the BOE's that accomodated the 'p40.
falcon
Hey kid, I am going to be 49 in June, take it from an old man [laugh] it is never too late to get a security system (unless you were robbed)!
We had some intrusion on our property just before the holidays (they didn't get in but they tried). I told my wife that I could make our own custom alarm system using PStamps.
She didn't want to wait so we went with FrontPoint. Its not like ADT, Brinks and the others... My house is in CONSTANT communication with the monitoring center. It handles doors ,windows, motion, fire, heat, smoke, water, freezing, carbon monoxide, gas detection, cameras, driveway sensors, lighting, and more. The sensor are all wireless and uses a phone line and built in cellular data phone. Even if someone trys to jam the system or cut the phone line, it knows because it lost comms instantly! Rather than spending all that money for a whole bunch of window sensors, I wired the windows to the nearest door sensor using tiny reed switches and magnets! That saved me a lot of money.
I can even control it all from my smart phone.
It sounds like your system has the same capabilities except for the monitoring. Look in the PBasic help for DTMFOUT, there is a nice circuit there that you can use to have your system call you and then send tones to let you know what is going on. You can even use a EEPROM and a DAC to send a recorded voice.
I built this when I was thinking about making my own system. Once triggered it would take over the phone line, dail a number, and start playing the digital message. Worked like a charm, but that is all moot now.
Anyway....
For a permanent project, go to Digikey and
Search for breadboards. Then find a cheap 40 pin socket. The whole thing should be about $20
If you are bold, goto ExpressPCB and download their free software. You can make your circuit board for about $100. Actually I think you get two that that price.
Good Luck,
Paul
I installed that ExpressPCB software over the Christmas break and I like it. I'm not familiar with the mor capable ($$) products but I think that will do what I need to do.
I'll take a look at your project.
falcon
I am a beginner.
I have made a serial connection b-n BS1 & BS2
Below is some code.
I had problems sending letters, but 3 digit numbers coming thru no problem.
Maybe the code below will be helpfull to someone.
This code is for BS1:
This code is for BS2: