Shop OBEX P1 Docs P2 Docs Learn Events
Is it going to work? — Parallax Forums

Is it going to work?

kymppikymppi Posts: 5
edited 2009-04-20 04:39 in BASIC Stamp
I have 16 push buttons in hand-held control device and I have been looking for a solution to convert these 5V TTL signals from parallel to serial and back again on the other end of the cable. Multiplexing is out of question and "normal" parallel to serial to parallel IC's don't work as needed. At least 74hct164 and 74hct165 doesn't work right way.

So is it going to work if I put those 16 signals to this Basic stamp module as inputs and it sends the data from Tx to Rx on other Basic stamp module and it convert it back to 16 outputs?

These modules should work without computer and wake up after power loss and continue working. Does it need any backup battery or something like that to keep programmed data in memory? It would be great if these modules work with 5V, but that's not a problem. Next problem will be programming this thing if it is suitable for this application.

Thank you for your help.

kymppi

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-04-19 14:45
    You haven't explained why multiplexing is out of the question and why ordinary shift registers won't work for you. What you're describing with the Stamps is just another form of multiplexing.

    Using the Stamps, one at each end, is simpler from a hardware standpoint. A Stamp has 16 I/O pins (except for the BS1 which has 8 and the BS2p40 which has 32) plus the programming pins (Sin and Sout) can be used for asynchronous serial I/O. They can work with either a 5V regulated supply or a 6-9V unregulated supply. They have an EEPROM which holds the compiled program and will just start up that program when they're turned on.

    There's lots of information on Parallax's website available for download. I'd suggest starting with the "Basic Stamp Syntax and Reference Manual" and the "What's a Microcontroller?" tutorial. Go to the main Parallax webpage and click on the Resources tab, then follow the Downloads link. You'll see some other links. The Stamps in Class Downloads link will take you to an index of all the tutorials and the BASIC Stamp Documentation link will take you to the Manual.

    Read the Manual's chapters on the SERIN and SEROUT statements and the DEBUG and DEBUGIN statements. There's also a chapter that describes how the I/O pins are accessed as 16 bit variables (INS, OUTS, DIRS).
  • kymppikymppi Posts: 5
    edited 2009-04-19 15:57
    Ok, let's explain this more accurate.

    Why I'm trying to this is because I need to install a LCD display to this hand-held control device and there is not enough free wires in the cable so that I could easily do it. So I need to free up some wires, because cable manufacturers won't make me a bigger cable because of small order amount and high price. I have 37-pole cable and there is one free wire. It is spiral PUR cable.

    I have understood that I can't use multiplexing since there can be many inputs on at the same time. I could use multiplexing with two rotary switches, because there is only one position selected at a time. Ok, I have two rotary switches (4-position and 6-position) and 6 buttons. Two buttons are some times pressed at the same time, so four inputs out of 16 can be on at the same time. There will be two more buttons added later and then BS2p40 would be a great choice.

    I have tried to make a circuit with 74hct165 and 74hct164 converters and either I can't make it right (possible, almost sure) or it doesn't work right. I managed to send 8 bit dip switch code from 74hct165 to 74hct164, but there is a problem in outputs. It seems to put first output on and then it moves it to the next output in every clock pulse. It's "running" effect. Those outputs should be steady. If I put one switch on, then corresponding output should be on immediately and that's it. If I put three switches on, then there is supposed to be three outputs on etc. I need to send these outputs to PLC and it will not work if outputs are going on and off like maniac. It will cause a disaster in the machine.

    And I'm trying to find as simple and easy solution as possible. I haven't been working with multiplexers or microcontrollers before. I haven't programmed either, except that LCD display. I desided to control it with PLC, because it's simple to just send hex codes to it and I need that PLC to handle measuring devices too. So it's not programming after all.

    But I read some manual about this module and quickly it seems promising. I'm eager to learn something new, but it's always better if someone who already knows something about this product can tell me if this is what I can use. I don't see the point just ordering some stuff and then after many working hours find out that this is not going to work. If this module is not ok for this purpose I don't see other way but going to some company and order this whole thing ready. Since they decided in UK that they won't send their products to Finland. There is also one ready module at Tronisoft, but they have made their decisions about shipping outside UK.

    Thank you anyway. I'll read some more about this product when I'm going to bed. I hope my girlfriend will understand it if I'm interested about something else tonight.
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-04-19 16:34
    This would be quite easy to do with two stamps, one on each end. You would connect each switch pole to a Stamp input, through a 1 kOhm resistor (for safety). The switches put out 0 volts in one state and 5 volts in the other state, right? (if not, you may need other resistors to set the levels to 0 and 5 volts.) Then the Stamp at the switch end will need a simple program like the following:

    ' transmits switch state on p16 at 2400 baud, 4 times per second
    DO
      SEROUT 16,396,[noparse][[/noparse]inL,inH]
      NAP 5  ' 1/4 second delay
    LOOP
    



    On the receiving end it could be as simple as the following, which waits for data to come in at 2400 baud and transfers it to the output pins to your PLC.

    DIRS = $FFFF   ' makes all pins outputs
    DO
      SERIN 16,396,[noparse][[/noparse]outL,outH]
    LOOP
    



    That is PBasically all that is required. Enhancements are possible, such as to transmit data only when switches change state. Snd if there is possibility of transmission error (noise coupled from other lines on the cable), then error checking and recovery may be advisable, and the Stamp can handle that, whereas a dumb shift register cannot.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • kymppikymppi Posts: 5
    edited 2009-04-19 16:54
    Thank you Tracy. This is exactly what I wanted to hear. And error checking... even better. I want that data transmission is continuous all the time.

    And yes I get 5V signal from switches when pressed and 0V otherwise.

    I have no idea what that program says, but when I start to study maybe it will open up for me. Maybe I can try this on Proteus simulation.

    And how many wires this connection between two stamp require?

    Thank you again.

    kymppi
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-04-19 17:42
    There is one data line that connects physical pin 4 on the transmitting Stamp to physical pin 4 pin 3 on the receiving Stamp. There also has to be a common, ground wire connecting pin1 on both of them. Also a power supply for each Stamp, which can be either 5 volts regulated applied to the Vdd pin, or a voltage from 5.5 to 12 volts applied to the Vin pin.

    The input pins are captured or activated as two groups of 8 inputs as INL and INH. Similarly for OUTS, OUTL and OUTH. The program is simply reading those pins and sending them out as arguments in a serial output command:
    SEROUT 16,396,[noparse][[/noparse]INL, INH]
    The pin to use for output is p16, which is the dedicated programming and debugging port on the Stamp, above and beyond the normal i/o pins, which are numbered p0 to p15. The value 396 sets the baudmode parameters, here 2400 baud, but there may be reason to choose some other baud rate. The matching command,
    SERIN 16,396,[noparse][[/noparse]OUTL, OUTH]
    receives the two bytes that were transmitted and transfers them directly to the 16 output pins. DIRS=$FFFF sets all 16 of the pins as outputs (The default is inputs). In this scheme, there will be a few milliseconds of delay between updating each group of 8 pins. If that is a problem, there are easy ways around it. The idea though is that you can probably get it to do what you want. And there is help here on the forums.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com

    Post Edited (Tracy Allen) : 4/19/2009 9:22:26 PM GMT
  • kymppikymppi Posts: 5
    edited 2009-04-19 18:19
    This is too good to be true. So now when I need 16 wires for these switches, I could do the same with two. Voltage supply is there anyways. And if I use that BS2p40 stamp I can put there up to 32 inputs. Couple of these stamps and I could do the whole connection with what, five wires instead of 36. Not bad.

    Thank you all. I will try this and if I have any further questions I will post them here.

    Best regards,
    kymppi
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-04-19 21:16
    The Stamps can quite easily interface to shift registers like the 74hc164 or '165 or '595, using the SHIFTIN and SHIFTOUT commands, so that is a cheap way to expand your i/o on the Stamp or to free up pins for other functions.

    Correction to previous posting: physical pin 4 on the transmitting stamp to physical pin 3 on the receiving stamp.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-04-20 03:49
    If I understood the original post – you need to send data to remote LCD.· You did not indicate you need to receive data from the remote.
    ·
    You want to encode the data into as few wires as possible and then decode it on the other end for display on LCD.
    ·
    You have 37 wires.
    ·
    How many wires are you using for your LCD?
    “Standard “ parallel LCD can be run with roughly 10 wires – including backlight and control signals.
    ·
    ·
    Your data should be encoded for proper display format. (No extra decoder needed at LCD).
    ·
    I bet you could find I2C chips / chips to interface with LCD – and now we are talking about 2 to 4 wires plus power. (That would be my choice)
    ·
    Not be picky – but any serial communication (RS232, I2C) is form of multiplexing and to be picky – it cannot be used “continuously” – it is a shared communication.
    Cheers
    Vaclav
    ·
    ·
    ·
  • kymppikymppi Posts: 5
    edited 2009-04-20 04:39
    Vaclav,

    I don't need to send data to LCD. All I need is to get 16 signals (in near future about 20 signals)·from switches to PLC. I need only one direction connection from hand-held device to PLC.

    LCD is working with serial connection and is controlled by other PLC.

    Yes I guess serial communication·is one form of multiplexing. I just need the·right kind of multiplexing and don't know how to do it with separate IC chips. By continuos I mean that connection is alway on. Not that it will turn on by every time some switch changes state.
Sign In or Register to comment.