Shop OBEX P1 Docs P2 Docs Learn Events
BS2p40 OEM chip design questions (MAX232, XTAL, RESET, etc) — Parallax Forums

BS2p40 OEM chip design questions (MAX232, XTAL, RESET, etc)

RobotWorkshopRobotWorkshop Posts: 2,307
edited 2006-08-28 16:19 in BASIC Stamp
Hello,

I've had very good results using the BASIC stamps and with the BS2SX OEM chips in previous projects. I am working on a new one that needed more I/O so I thought I would give the BS2p40 chip a try. At the moment I have it wired up and am trying to use a MAX232 as the level converter for the Serial connection to the PC. Everything seems to be wired up properly but the Host PC can not find the Stamp chip (the field is empty) and will not download any programs to it. As I troubleshoot the problem I would like to see if anyone else has done something similar and perhaps could answer some questions:

QUESTIONS ABOUT BS2p40 OEM USE:

1. I'm using the Surface mount OEM BS2p40 chip with the through hole 20Mhz resonator and the 8-pin DIP EEPROM (24LC128). Does it matter if the through hole parts (resonator, EEPROM) are used or will they have to be switched to the surface mount parts?

2. For the connections of the EEPROM chip to the BS2p40 i've got a 4.7K pull-up on the SDA line but not a pull-up on the SCL line. Should that also need a 4.7K pull up?

3. On the through hole 20Mhz resonator there is a 5.1pf cap from the outside lead to ground. This is the one that goes to pin #3 of the BS2p40 chip. There is a 10K resistor that goes to each outside lead of the resonator, Of course the center lead is grounded and the other outside lead goes to pin 2 on the BS2p40 chip. Would these values for the resistor and cap only be valid for the surface mount resonator and should they be changed for the through hole part?

QUESTIONS ABOUT MAX232 USE:

4. When using a MAX232 chip I guess that the two .1uf caps external to a real BS2p40 module may not be needed. I've seen a couple examples that use such a chip and instead have a small signal diode comming off the transmit line going toward the PC and a 4.7K resistor on the output of that to the receive line. Does that sound correct for a MAX232?

5. For the connection of the MAX232 to the stamp I directly connected the TTL side of the MAX232 to the appropriate pins on the stamp (Pins 8,9) which should be fine. The question however relates to the RESET line. I've got the DTR (from pin 4) going to the MAX232 and then the output to a 4.7K resistor which then goes to the Stamps RESET pin 1. Should there be a pull-up as well or just a pull-up and ditch the in-line 4.7K. I expect that something should be in-line to account for another device eventually driving the reset line.

If anyone needs any more details just let me know and i'll add them in another post.

Thank You!

Robert

Comments

  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-08-14 18:53
    1) Should be no problem mixing surface mount and through hole.

    2) The pullup is needed on sda only, not sck.

    3) You willl find that the part is remarkably insensitive to the parts used with the resonator. The capacitor a osc2 will make the oscillation an nicer sine wave and decrease the current consumption slightly. Measure the voltage at pin 3. It should be around 2.5 volts if you have oscillation, and if you have a scope, you should see a 20 mhz sine-ish wave there. If you probe pin 2, the amplitude will be less, but the oscillation may stop unless you use an x10 probe.

    4) The resistor from transmit to receive is necessary to provide the echo that is expected by the programming IDE. The diode is necessary also for the echo, so that signals coming in on the receive line will loop back onto the transmit line. The MAX232 would otherwise clamp the line at a low level.

    5) There should be a capacitor in series with the ATN line. This is not necessary for the programming IDE, but it is desireable if you want to communicate with standard comms software like hyperterminal. Without the capacitor, a constantly asserted high on the DTR line will hold the Stamp in reset. Put a pullup resistor (4.7k) on the ATN line (pin 1 on the chip) and connect a 0.1uf capacitor to the MAX232.

    I don't know why your setup is not working, though. Check the voltage levels. Look for activity on the serial lines.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2006-08-14 19:31
    Hello Tracy,

    Thanks for your response. That clears up a lot and provides and confirms quite a few things that I thought I knew but wanted to be sure. I still have a question on question #5 however. I gather from that pin 4 connection for DTR on the 9-pin Serial connector can go directly to the input of the MAX232 and then the TTL output from that should be coupled via a .1uf cap to the RESET line. The RESET line should also have a 4.7K pullup. If that is the case then all I think I have to do is swap out the 4.7k resistor I had inline on the output of the MAX232 for that line with a .1uf cap and that may fix it.

    This evening I can give it a shot. If that doesn't do it i'll dig out the scope and probe around a bit to see what all the signals look like and how they react when I power it up and try to identify the chip and download a program to it.

    Robert
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-14 19:42
    Robert,

    ·· The effect that you want is that when the DTR line goes HIGH it takes the ATN line HIGH as well, but then we use capacitors on our boards to prevent the DTR line from holding ATN high (They block DC).· So only a pulse is required (HIGH pulse).· ATN should be pulled LOW, as per our schematics, so that it doesn't float.· I hope this helps.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-08-14 20:08
    Chris, I think Robert is DIY, so he is taking the signal directly into the active low mclr\ line, pin 1 on the chip. The MAX232 is inverting the pulse. Mclr\ needs to pulse low when DTR goes from low to high.

    Robert, most MAX232 series devices have a pulldown resistor built in (~5kohms) on the receiver inputs. As an alternative to the RC on the Stamp TTL side, you could use tie a 0.1uf capacitor from DTR to the MAX232 on the receiver input side. The builtin pulldown resistor there would work so your wouldn't need to add one. That would also produce an low pulse on mclr\ when DTR goes from low to high. You could probably leave the 4.7k resistor you have already from the MAX232 to mclr\. That is a high impedance input.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-14 23:09
    Okay, given that I guess the only thing you may need is a pull-up on the /MCLR line if the MAX232 doesn't have that.· I guess I need to start using the MAX232 more.· I used to use the 1488 and 1489 (+/- 12V requirements) and then I got into BASIC Stamps and starting using the transistorized circuit, or the USB2SER.· Time to dig out that datasheet...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2006-08-15 03:29
    Hello, I did a little more testing but unfortunately I didn't make much progress. To start I made sure there was a 4.7K resistor across the transmit and receive lines on the PC side of the MAX232. There is also a small signal diode in place on the transmit line (band toward PC). I also tried using .1uf caps on the DTR line (one in-line and one to ground) but they did not make a difference. I suppose that mainly matters if I were going to use that Serial port for something other than programming.

    The scope is stored away at the moment(may need to dig it out) so I started poking around with the logic probe to get an idea what it going on. Here is what I found so far:

    - When I run the Identification I end up with a blank device type and both loopback and echo say YES. With the stamp idle I watched the /RESET line on the CPU and it is normally HIGH. When I start the Identification routine I see that /RESET line pulse low (6 times) and I also see activity on the Rx line back to the CPU. I never see the stamp trying to send anything back however. It appears to me that it is toggling the /RESET line low.

    - I've also tried a different resonator to rule that out.

    - The logic probe also shows activity on the SDA and SCL lines so I assume it may be trying to talk to the EEPROM.

    - The only example i've seen using the BS2p40 chip is the schematic for the BS2p40 module itself. In particular the REV B drawing from 5-11-04. Is that drawing correct and are the pins in that order? I've been using the pinout on the BS2p40 chip in that drawing as a guide. It shows that pins 5, 19, 33, 47, and 48 should be ground. Pins 4, 18, 32, and 46 should be +5v. Pin 1 is /RESET. Pins 2,3 are for the resonator, pin 6 is the SDA to the EEPROM and pin 7 is the SCL to the EEPROM. Pin 8 is the Rx and Pin 9 the Tx for programming. The rest are all just I/O.

    I'm pretty sure that the Serial port on the Laptop is ok since i've been using that to program a BS2SX chip (OEM) and that worked the first time.

    Does anyone have an image (from a digital scope perhaps) of what the clock signal should look like at each resonator pin?? That would be helpful.

    I'm going to go over all the connections (yet again) to make sure i'm not overlooking something. I'm looking forward to figuring this out since I want to start using the chip.

    Best Regards,

    Robert
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-15 04:59
    Robert,

    ·· Pinouts can be confirmed by reading the datasheet for the SX48, which is also on our website.· I hope this helps.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-08-15 06:39
    The pin connections do sound correct. Be sure you are using the latest version of the IDE. The BS2p chip you have probably has the the latest firmware and you will need the latest IDE in order to program it.

    Also be sure all the unused address lines on the eeprom are grounded.

    Did you measure the voltage on pin 3, the oscillator output? If that is around Vdd/2, that is a good indication it is oscillating. The waveform there should be a little less than a rail to rail square wave at 20mhz, and it is the average that gives the 2.5 volt reading on a DC meter.

    I was a little confused by this statement: "When I start the Identification routine I see that /RESET line pulse low (6 times) and I also see activity on the Rx line back to the CPU. I never see the stamp trying to send anything back however. It appears to me that it is toggling the /RESET line low."

    What are you referring to as the "CPU"? Is that your PC, or is it the SX/Stamp? The perspective for "rx" and "tx" can get confusing.
    * mclr\, pin 1 on the SX chip should be normally high and pulse low briefly 6 times (as you noted) as the IDE tests in turn for the BS2, BS2sx, BS2e, BS2p, BS2pe or BS2px. The DTR signal from the PC comes in on pin 4 of the DB9, through a (optional) 0.1uf capacitor to one of the Rin pins on the MAX232, inverted at the corresponding Rout, and then over to /mclr on the SX.
    * Data from the PC come in on DB9 pin 3, to the other Rin on the MAX232, inverted at the corresponding Rout, and then to ra2, pin 8, on the SX.
    * ra3, pin 9 on the SX chip sends data to one of the Din on the MAX232, inverted to RS232 levels on Dout, through the diode, to pin 2 on the DB9.
    * There is a ~5k resistor effectively from pin 2 to pin 3 on the DB9.
    * mclr\, ra2 and ra3 should all be normally high, and low intermittently when talking. The corresponding signals on the DB9 side should be low or negative and pulsing high only when talking.
    The power supply should be a clean 5 volts.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2006-08-16 06:31
    Hello Tracy,

    I was using the BASIC Stamp software Version 2.2.5 but noticed there was a new version 2.2.6 out which I just tried. Unfortunately that did not solve the problem.

    On the EEPROM pins 1,2,3,4, and 7 are connected to gound.

    Using a voltmeter on the two outer pins of the resonator gave a reading of 1.36v on the lead going to pin 3 of the BS2p40 and a reading of 2.25v on the one going to pin 2 of the BS2p40. The +5v power is being provided by a 5v voltage regulator connected to a 12v 7ah gel cell battery. It gives a solid reading of 5.01v so I am pretty sure that is ok. The +5v regulator is rated at 800ma.

    It was getting late and I had a typo there. Sorry. I was using the term CPU to refer to the Stamp and what I meant was that as I saw the /RESET line pulse low that I also saw activity on the BS2p40 Rx line (being sent by the PC's transmit line to the BS2p40)

    Now at least I know why it pulses 6 times! Would that mean if it found the BS2p40 that it wouldn't need to send the other two for te BS2pe and BS2px?

    I'll have to see about pulling out the scope tomorrow and take a look at the clock signals. Either i've been looking at it too much and overlooking the same thing or maybe something happened to the BS2p40 chips. They seem pretty robust so i'm going to assume for the moment that I need to keep digging.

    Thanks for all the help and support!

    Robert
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2006-08-18 17:16
    I've been reading the "BASIC Stamp Programming Protocol v1.1.pdf" file (although I can't seem to find the link on the Parallax site anymore) and it does describe the entire identify sequence and helps show what I should expect when trying to identify and then program the BASIC stamp chips.

    You had mentioned that it sends out 6 attempts to identify the different Stamps. From the documentation it talks about 5 but I assume that needs to be updated to note that 6 should be sent out instead since the BS2px isn't mentioned and I expect that is the sixth one to be added. Hopefully someone from Parallax will read this and confirm that.

    Just in case I did something to damage my original stamp during handling, soldering, etc. I just picked up a couple more of the OEM chips from Parallax. This evening i'm going to install one and see if that makes a difference. I noticed that the new ones now have "Parallax" printed on the top so they are probably the latest version.

    Will post the results once I try it out.....
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-18 17:26
    Robert,

    ·· I wanted to confirm that the pulses are as Tracy described.· The document has not yet been updated to include the BS2px.· As for the link on our website, it is listed below.· I hope this helps.· Take care.

    http://www.parallax.com/html_pages/downloads/tokenizer/tokenizer.asp

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2006-08-27 01:04
    Hello,

    I have good news! Everything is now working as I expected it should. There were a couple problems, one of which was really odd and completely pointed me in the wrong direction to getting this working. The other problem was that the EEPROM chip was bad and as a result it would not let me download a program. I have that socketed so replacing that was easy!

    The main issue I had in getting the BS2p40 OEM chip (w/MAX232) to talk to the PC is that I had made a silly mistake wiring the TX/RX (pins 2 and 3) on the DB9 connector. I had them swapped. No wonder it wasn't working. The really weird part was that a real BS2p40 module would work with the 9-pin connector wired wrong. Since that worked I kept going over everything and it was right and had to work. Then I swapped pins 2 and 3 on the DB9 and low and behold it worked!! I connected the real BS2p40 stamp and it still worked.

    So, there appears to be an odd side effect with the combination of resistors/transistors used on the BS2p40 stamp from Parallax which allows it to work and function with pins 2 and 3 wired either way!!! If you have a MAX232 or other serial line driver it only works if it is wired correctly. Since the stamp was functioning ok with the wrong wiring it threw me off the trail. If it had not worked then I probably would have found the wiring error right away. I have confirmed this (unexpected) behavior of the BS2p40 stamps pin 2 and 3 oddity (allowing the pins to be swapped) on two different systems (desktop and laptop) and it worked if the pins were right or swapped! Has anyone seen this or tried it before?? If not i'd like to see if anyone else can try and reproduce it as well. The swap was at the actual 9 pin connector and everything was wired ok.

    At any rate I am glad the mystery is solved and truely appreciate the feedback on this forum!

    Now that i'm able to use the OEM BS2p40 chips I may give the SX chips a whirl since I should be able to use them on my board with a few slight mods.... (But that is a topic for a different forum)
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-28 15:52
    Perhaps I could shed some light on why it's working backward, although it probably shouldn't be...As you know there is a 4.7K resistor in the schematic which goes from the SIN to the SOUT line.· This serves a few purposes, but most notibly echo.· But since it's a path of relatively little resistance it would stand to reason that signals could pass through the resistor into the opposite pin.· It may be that the transistorized circuitry on the BASIC Stamp Module allows this to work, while the MAX232 does not.· Do you have the 4.7K resistor across the RX/TX pins?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2006-08-28 16:08
    Hello Chris,

    I am using a 4.7K resistor between the RX/TX pins like the regular Stamp module. It also has a small signal diode on the TX pin as required when the MAX232 is used. I suppose it may be the diode or just that the MAX232 has more of a true RS232 signal swing which is why it doesn't act the same. It's obvisously not an issue since I wouldn't expect it to work with pine 2 and 3 wired backwards anyhow. I'm not complaining but just thought it was odd that the Stamp would work fine either way. It was completely unexpected and was curious if anyone else had mentioned it or run across this before. I'm just glad i've got everything wokring now.

    Best Regards,

    Robert
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-28 16:19
    Robert,

    ·· Yeah, it sounds like it's just a side-effect of the feedback resistor on the line.· Glad you got it figured out.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.