1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Circuit for replicating bell codes - any suggestions

Discussion in 'Electronic Projects Design/Ideas/Reviews' started by LeedsNorth, Jan 3, 2014.

  1. Mike_2545

    Mike_2545 Super Moderator

    Joined:
    Jan 4, 2009
    Messages:
    1,057
    Likes:
    29
    Location:
    Toledo, Ohio
    A simple uC approach would be the Basic Stamp. they run about $50 usd and don't need any other hardware except a "carrier board". The software is free and programming is fairly simple.
     
  2. ChrisP58

    ChrisP58 Well-Known Member

    Joined:
    Apr 27, 2012
    Messages:
    1,081
    Likes:
    131
    Location:
    Provo, Utah, USA
    One other question to ask your self when considering what path to take on a project is, What new skill set will I learn here that I can carry forth into my next project?

    Up till about twenty years ago, I did everything digital with gates, counters, flip-flops, mux/demux, etc. And it took me awhile to get my head around doing a project with a uC, But now I don't even consider discreet logic as an option (except as peripherals in a uC circuit).

    One BIG advantage software has over hardware is when it comes to debugging and system changes. I still remember the hours (or days) i spent tracking down logic that didn't quite work right, then the time and efforts spent re-wrapping a wire-wrap board, or cutting and soldering in jumper wires on PCBs. Now, finding problems and fixing them is much easier and faster.

    As for the cost of a software development system, you need to remember that it is a one-time investment that can be used on many projects. And, once you have a new skill set under your belt, your mind automatically starts looking for new places to use it.
     
  3. rogs

    rogs Member

    Joined:
    Oct 3, 2009
    Messages:
    148
    Likes:
    4
    Location:
    UK
    I think the problem here is the fact that the configuration is slightly odd. (Up to) 24 individual mutally exclusive input switches (possibly individually illuminated?) and only one output required (to drive a single bell activation relay).
    Not difficult of course, but the peripheral 'glue' needed to interface that configuration with most simple uCs will require almost as much hardware as simply doing it in hardware anyway!
    The ability to address up to 24 individual '16 bit' binary sequence outputs is not exactly going to tax the capabilities of a modern uC....
    The extra hardware, over and above the input and output and output interfacing 'glue' needed anyway, is minimal in this case (one flash chip, and 4 x 4000 series chips at less than $1 each).
    If you want to use the project to acquire new skills, using modern electronic devices, going for the uC approach is the answer.
    If you want to build a one off 'block signal' simulator, then I still think it would probably be simpler using the kind of hardware I sketched in post #36.
    I suspect the final decision will really depend whether the OP is hoping to do more uC projects in the future?......
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. ChrisP58

    ChrisP58 Well-Known Member

    Joined:
    Apr 27, 2012
    Messages:
    1,081
    Likes:
    131
    Location:
    Provo, Utah, USA

    24 momentary switches can easily be setup in a 4x6 array using 10 I/O pins and no additional ICs.
     
    Last edited: Jan 7, 2014
  6. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,916
    Likes:
    1,097
    Though 16 was the initial number. Then there was a change to select one of two bells. That could be done with a SPST/SPDT switch.

    3 resistors is about all for the peripheral glue assuming the KIT. The SDL, SCL pull ups and the interrupt pull up.

    One has to build the kit. I think a SIP header needs to be added to the board to access the I/O. Maybe a few traces have to be cut to break out SDL/SCL and an Interuupt.

    You can use the ULN part to drive an LED, but don't really have to.

    T
    Ypu have to be able to encode a sequence like 0%04-04-04-04* for example. and 1%16 is also a code in my encoding in text form.

    The number of dings is 2 digits. The "-" is a short pause. and the % is a long pause.

    In fact, you could encode it as A04-04-04-04% where A is attention. which is 1 bell followed by a short pause. I'll show % as the end of the string. Thus A16% would work too.

    There is any number of ways of encoding, that's just a possible idea. Hard coding is an option too.

    You might even prefer a fixed byte structure with say a null (255) being a NO OPeration. Set the 128 bit and it's a control.

    128+0 could be a NO OP
    128+1 or 129 could be a short pause
    128+2 or 130 could be a long pause
    255 or could be end of data

    So a fixed matrix like
    00: 001 129 004 129 004 129 004 129 004 130 255 for attention and 4-4-4-4 followed by a long pause
    01: 001 129 016 130 255 000 000 000 000 000 000
    ...
    15:
    for Attention followed by a long pause and EOL.

    So you could index into the array, If you used a power of 2 for the array size, computation would be easier.
    e.g. 16 codes x 16 bytes

    It doesn't look like the OP adequately described the problem.

    Aside:
    A solenoid driver might be a better choice for driving the bell.
     
  7. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,916
    Likes:
    1,097
  8. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,916
    Likes:
    1,097
    Here http://www.picaxe.com/docs/picaxex2.pdf is basically one of the missing documents needed to understand the parts. I think the 20X2 series and the AXE118 kit combined with the PCA chip will work for you.

    This document tells you what pins have to be used for SCA, SDA and INT1 or INT2.

    The pull down resistors, if any, would have to be converted to the proper pull-up resistors and probably a few traces would have to be cut.

    It looks as it the 20X2 parts will output 3.3 V for a high and not 5V. Just a guess based on the info in the above PDF.

    Easy enough to use one of the ULN ports for a LED.
     
  9. rogs

    rogs Member

    Joined:
    Oct 3, 2009
    Messages:
    148
    Likes:
    4
    Location:
    UK
    Your comment got me thinking about a keyboard matrix option... and that led me on to considering a DTMF keypad... and the cheapest version of that is probably an old telephone.....(well to test out the concept anyway!)

    Now, if you do use DTMF as the switch instructions, then the hardware gets even easier ( and cheaper!). Concept sketch of that idea attached..... (just add up 3 more decoders to extend the input switch count up to 64, if required)..
    (I'm determined to prove there is a viable hardware option :) )

    Of course, if the OP wants to use this project to learn about uCs anyway?.......
     

    Attached Files:

  10. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,916
    Likes:
    1,097
    rogs:

    I understand the addressing, but how are you doing an arbitrary length sequence with two different delays.

    Attention is 1 bell and a space. this space should be longer than the code, I think.

    S, you get
    ATTENTON
    16 bells+delay for the command

    or
    ATTENTION
    4 bells+delay repeated 4x

    A few commands don;t get the attention signal.

    This is like morse code.
     
  11. rogs

    rogs Member

    Joined:
    Oct 3, 2009
    Messages:
    148
    Likes:
    4
    Location:
    UK
    As I say, it's just concept sketch.... no point in doing any detail if it's not going to get built!........ :)

    Re: the timing..... at the moment, It's drawn with just A0 connected to the flash address buss.....

    ...Valid code received, is latched into the 8870, and presented to the flash data buss. Valid code flag (pin 15) goes high on the 8870, sets the RS flip flop, and starts the clock.
    The 8 'bits' of the flash word being addressed(whether they be highs or lows) are scanned through the 4051 by the 4040 counter. (Q0 - Q1 - Q2).
    Q3 is connected to A0 of the flash address, which then goes high after the first scan, and lets the next stored data word be scanned through the multiplexer as well.. When Q4 goes high, the system is reset until the next valid code.

    If it's necessary to use more flash 'words', to allow for different timings (say 'hi' for one count for the bell and two 'lo' counts for a space?), then simply adding the Q3 counter output to the flash address buss as well - and resetting the system from Q5 instead - would allow 32 time 'slots' to be read... which could be programmed as required, to get the timing 'right'.

    It would of course mean that the 'space' timing would need to be a multiple of the 'bell' pulse , but the few examples I have heard online don't suggest it's that critical (the sequences were entered by hand.... like manually keyed 'Morse Code', as you suggested.)
    Examples - about 25 seconds into this video:

    or the first 30 seconds of this one http://www.yourepeat.com/watch/?v=lN7q3KbqRw0


    Certainly those samples seem to have a typical 'gap' timing about the same spacing as the bell.
    Although of course the monostable connected to the multiplexer output needs to be adjusted to allow the bell 'hammer' (solenoid?) to strike, and then fall, much more quickly than the whole time period, to allow the bell to sound 'right'.....(just a short 'ping' of 100 - 200 mS, I suspect?)
    So, it would simply be a question of adding longer programmed sequences into the flash. (say 32 per sequence instead of 16?). You could go further and make it 64 -- there are plenty of counter outputs, and spare flash locations to address!...
     
    Last edited: Jan 11, 2014
  12. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,916
    Likes:
    1,097
    <self-deleted - wrong thread>
     
    Last edited: Jan 10, 2014
  13. LeedsNorth

    LeedsNorth New Member

    Joined:
    Jan 3, 2014
    Messages:
    22
    Likes:
    0
    Afternoon all,
    Right, sorry long shifts at work the past three of four days have kept me away from this project, so apologies for the lack of response. I should be ok for next couple of days!

    Yes, I'd agree entirely. I've emailed a railway technician I know - he's never actually had anything to do with these bell instruments, but knows a few people that have, so he is going to ask and come back to me - that should get it defined once and for all.


    Lol! Just a little! I'm getting there tho. I keep reading through things, and find that im understanding more each time!

    Soldering is fine, so more than happy building a protoboard project. I have played with blank PCBs in the past (not in any detail I hasten to add) but managed to get on ok with it all, so putting it all together does not cause me any concerns!

    Andy
     
  14. LeedsNorth

    LeedsNorth New Member

    Joined:
    Jan 3, 2014
    Messages:
    22
    Likes:
    0
    I have to say im very, very impressed with all you guys. Not only for the interest, and help, but also for actually understanding what im talking about and finding the various pictures/reference videos! Well done!

    Certainly no regretting asking for suggestions! Im no expert at electronics, I just wanted to find the best way of getting an outcome for the project and maybe learn something at the same time! You guys have certainly helped me on both fronts! What I dont want to do is to find an outcome and have absolutely no idea how it works or does what it does, I need to understand it - a) for troubleshooting, but more importantly b) for future reference, and doing other things!
     
  15. LeedsNorth

    LeedsNorth New Member

    Joined:
    Jan 3, 2014
    Messages:
    22
    Likes:
    0
    Apologies if I've misdescribed something at the beginning. Bear in mind in the first of the video clips referenced, there are two independent bell codes. The first - a single bell - is simply to get the signallers attention. Nothing else happens until he repeats that back, then the actual message or 'bell code' i.e. 3 bells-pause-1 bell is sent, to which the signaller repeats it. In the situation with the electronics - simulating the first part, is done by pushing Button 1. The second part of the message (3 bells-pause-1 bell) is done by (for example) pushing Button 9. The gaps between the two different codes are not recreated by the electronics - that is down to the staff demonstrating it.

    Andy
     
  16. LeedsNorth

    LeedsNorth New Member

    Joined:
    Jan 3, 2014
    Messages:
    22
    Likes:
    0
    Hi Rogs,
    Totally correct, its not critical. One of the older signallers told me when he started working as a signalman, he was told, long as you can distinguish between a short pause and a long pause, your doing fine! Generally, when you watch the railwaymen working the machines, its around a short pause of 4/10ths of a second, and a longer pause is 8/10ths of a second. But im being more precise then we need to be!

    Andy
     
  17. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,916
    Likes:
    1,097
    So, the "long pause" is the start of another message?

    It was unclear that ATTENTION had to get a response from the other documentation found online. Note that some codes actually begin with a 1 and some don't require it. I think 16 bells didn't require the ATTENTION signal.

    Ah, so your idea is to select one of two bells demonstrating the receipt? i.e. The other bell is supposed to ring to replay to a message?
     
  18. rogs

    rogs Member

    Joined:
    Oct 3, 2009
    Messages:
    148
    Likes:
    4
    Location:
    UK
    This of course is at the heart of your dilemma. Building something in hardware - perhaps along the lines of my post#48 sketch - would require you to have some comprehension of simple logic functions, including NAND gates, binary counters and a simple multiplexer. All fairly standard (and cheap!) stuff.
    But that's it. Once it's built and tested it should work pretty much forever! If the circuit is built as is finally drawn, then troubleshooting can be carried out by virtually anyone with a basic understanding of simple electronics.....

    For a software uC based project, some of the above is still true. You will need to have some peripheral 'hardware' electronics in addition to the uC itself. It maybe less than doing the whole project in hardware, although as you can read from some of my posts above, I don't necessarily believe that's the case with this simple project.
    What you do have to do in addition to constructing your uC hardware is write software code to make it all happen.
    So you have two new skill sets to learn - simple electronic hardware construction and code writing.
    future troubleshooting will then depend on the quality of not only the hardware itself, but also of the coding and it's documentation. In my experience, if the original coder is no longer involved with the project, then it can be very difficult to fault find.... or find code 'bugs'.
    If it's all down to yourself, then there should be no problem. (Although you will have to acquire both hardware and software fault finding techniques!)

    As you may have guessed, I come from a hardware background , and can see just how much will be dependent on uC control in the future. However, for simple projects like this, I think hardware is still a good option. So much simpler in concept.... I'm sure others will disagree!:)

    BTW, although we have been suggesting keypad switches for your inputs, I was wondering if you would rather have the option to be able to add as many switches as you need individually, with each one being a momentary switch, which illuminates when active, and includes logic to inhibit further activates while the system is 'busy'?
    To achieve that, you could make individual switch latches (which are connected together via a small ribbon cable) for about a £1 each (plus the cost of the switch).
    The keypad option would be cheaper, but might not suit how you intend the system to be remotely activated?......
     
  19. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,916
    Likes:
    1,097
    @ rogs

    I've been suggesting individual switches, you have been suggesting multiplexing switches.
    Multiplexing adds complexity.

    He is apparently in the uk and even closer to get the PICAXE stuff. That could be expanded to 16 * 8 addresses easily, I think. This assumes that there are 3 address bits that are set externally. For every 16 inputs, another I2C chip is added to the bus.

    The DTMF phone pad idea for a keyboard is an interesting one.

    I doubt that he will be able to afford 16 * $15.00 USD for the suggested switches. They are just plain nice, though.

    All he has to do is:

    Build the AXE118 kit and modify at most 3 resistor locations and possibly cut a trace.

    The only board he really has to build consists of one chip, a bypass cap and a connector for SDL SDC GND +5. I think this is the suggested order, so you don;t accidently blow up anything if the connector is reversed. Polarized connectors or blank pins are ways of circumventing that.

    Based on my kit, no headers are included.

    There could be two 8-pin SIP headers with a 0.100 inch pitch which probably won't support a polarized header.

    One is for access to the outputs and another is for access to the inputs.

    And there is a place for a 2 X 0.200" input header and a 2 X 0.200" output

    They use a SIP pack on the inputs and one will probably have to be cut.

    There are two places to put a 1 x 0.100" 5V supply in a daisy-chain configuration. That spot may support one polarized header.

    OK, you made me look for the 20x2 part.

    Pin 9, SDO, (pin 1 of the SIP) is an input, so the pull down has to be cut and changed to a pull-up. It might be a good idea to socket the RA1 SIP. So a bottom mounted resistor.

    B.0 (INT1) and B.1 (SDA) also require a little bit of surgery. Cut the connection to the ULN chip. It may not be necessary to ground the unconnected inputs, but worthwhile to do. Wire wrap wire works well for this.

    Again, change to pull-ups by putting resistors on the bottom.

    So, you would end up with two 8 pin connectors and one 2 pin connector going to the board and 5 or 7 wires leaving.

    SDO
    SDL
    Ground
    +5
    INT
    Bell - Logic
    Ground - for the bell

    Tentative because not sure if the ULN chip can drive the bell directly. At a minimum, a LED can be driven with the ULN chip on the board. So, that will work for debugging.

    How many connectors is arbitrary:

    SDO
    SDL
    Ground
    INT

    +5
    GND
    Null just to make it 3 pins.

    Bell - logic drive
    GND

    This would break it down into I2C, power, and Bell connectors and it means that one could disconnect the bell when debugging. For that matter, one could use a center-off switch and have bell1 - off - bell2 if one desired.


    A quick board nneds to be built using the surface mount adapter with connections (header) to the switches and a bypass cap, with the I2C bus signals, power and ground.

    The bell driver is not on the table yet.

    I have not used Meanwell power supplies, but they seem to be one of the cheapest. e.g. http://www.trcelectronics.com/View/Mean-Well/SP-75-12.shtml might be appropriate. ebay is another option especially sureelectronics for high current supplies.

    Excuse the wierdness like initially not including power and ground because of the "thinking out loud" part.

    I'm trying to figure out how I would build it, if I was going to. Overall space does come to mind.

    This http://www.ebay.com/itm/DTMF-Encode...750?pt=LH_DefaultDomain_0&hash=item19dab825a6 could complicate and/or simplify things. I'll link to the documentation separately: https://skydrive.live.com/?cid=556ed1951d776712&id=556ED1951D776712!109

    It goes from and I2C to a UART interface with an easy to mount keypad with no expandability.
    You can't have labeled buttons and the power supply requirements is 7 to 16 VDC. The interface is serial TTL or sometimes called TTL RS232.

    See, how much fun it is designing something simple?

    Time, cost, learning curve, repairability, expected lifetime, size, expected quantity, manufacturabilty, etc.

    You could build two innards and be able to swap for a quick repair.

    Somehow, I doubt the OP will have difficulty with the programming.
     
  20. rogs

    rogs Member

    Joined:
    Oct 3, 2009
    Messages:
    148
    Likes:
    4
    Location:
    UK
    I'm in the UK too, so recommending component suppliers might be easier?.....:)

    I started out suggesting individual switches ( see my sketch in post #36), but other posters suggested that a 'matrix' might offer a better solution when using the uC option ( see post #44) .. so I included a cheap (DTMF telephone) sketch option for that in my post#48.
    Individual switches obviously offer the most flexible option......

    At the end of the day, LeedsNorth has to decide whether a software controlled uC system, or a simple hardware option is the way for him to proceed with this project.
    Further suggestions involved with progressing design details in both directions simultaneously is only going to confuse....because they are likely to be so different!
    I certainly don't feel inclined to get involved in any further 'point scoring' exercise over which option is 'best'.. (I'm probably guilty of that already :))

    If LeedsNorth wants to consider the hardware option, then I could maybe take the next step, and add some detailed pin connections to my earlier concept sketches?....
    But if he decides he would prefer taking the uC option... then it's over to you software guys! ....:)

    (Not an easy decision for an electronics 'newbie' to have to make...:arghh: )
     
    Last edited: Jan 11, 2014
  21. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,916
    Likes:
    1,097
    Nice points.

    Matrix Scanning

    http://www.8051projects.net/keypad-interfacing/connection-diagram.php

    This is a tutorial using 8051 assembly language, but just wanted to introduce the concepts. You should be able to do variations using the I2C bus as well.

    With the 16 port device, you could:
    1. Use output pins of the processor (say 4 bits) and use the 16 inputs in an interrupt scheme.
    2. Use the 16 pit I2C chip configured as 4 in and 4 outs with interrupts as well.
    3. Use 4 inputs and 4 outputs directly.
    4. If you were short on output ports, you could do a 4 x 4 with 2 outputs and the interrupt scheme as well. Using a data selector/multiplexer as the front-end. 3 bits would give you 14 output positions + 0.

    All sorts of ideas.

    Matrix vs. Individual switches is a choice you have to make.

    See: http://uk.rs-online.com/web/c/?sra=oss&r=t&searchTerm=matrix+keypad&x=0&y=0

    This keypad http://uk.rs-online.com/web/p/keypads/0146272/ supports both a matrix and common point interfacing, so that's a non-issue at this point.
     

Share This Page