Continue to Site

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.

  • 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.

Circuit for replicating bell codes - any suggestions

Status
Not open for further replies.
I never mentioned an EEPROM on the I2C bus, but the processor has a means of storing info for program execution. This cannot be I2C. I2C EEProms are designed to store configuration data. Often EEProms have to be erased in blocks.

I did mention this chip which is a PCA8575: https://www.google.com/url?sa=t&rct...pOYQQCnRgxetOEDSvLaCiWw&bvm=bv.58187178,d.cWc

At this point, let's just assume that the part will work. One drawback is the package is surface mount. There is a company (www.proto-advantage.com) that will purchase chips from www.Digikey.com and place them on a DIP adapter for a very small cost.

So, in simple terms, the IC can detect a change in state and generate an interrupt. When the state is read, the interrupt is cleared.

What more do you want?

Well, some software that prioritizes, ignores and/or aborts a sequence if two are pressed at once. Your choice.

so, the processor spends most of it's time doing.

(Pseudo code)
100 sleep 1000
Goto 100

or if the uC supports it; Wait for Interrupt.

I2C is actually a multi-master multi-slave protocol, but I don't think it is here.

Many chips, have a way of specifying external to the chip a few addressed that it responds too. AD0, AD1 and AD2 pins do exactly that. That allows you to place eight of these chips on one I2C bus.
 
Another idea! Use an old PC with a parallel port. You can write the code yourself in VB or even in MSDOS Basic. We can help you with driving the bell from a PP output pin. I get old laptops for projects like this at garage sales...
 
Hi,

You can drive almost anything with an NPN bipolar and base resistor driven from the uC port configured as output, so there isnt much to worry about there. If you like N-MOSFET's you can use those instead. If you have a 12v power supply then regulate it down to +5v for the uC chip then you are good to go. Typical small and cheap regulators are the 78L05 and the LM317L, and the latter here requires two voltage set resistors. They will both take an unregulated 12v supply and regulate it down to +5v for the uC chip.
Once you have the regulator and uC chip connected on a board, you can add transistors with base resistors later for the peripheral device drivers like the bells and LEDs. Small LEDs like the 20ma type can be driven right from the uC port pins with a series current limiting resistor.

As far as choice of uC chip, i think people go with PICAXE and Arduino for simplicity, but you should keep in mind that these choices are more expensive if you intend to build a lot of these circuits. For a cheaper alternative you might look into the PIC chips (just "PIC" no "AXE"). They are made by Microchip and that company has a site you can visit. The PIC chips run as low as 2 dollars USD each and sometimes even cheaper, and that is with analog to digital converter and various other features too. If you know programming and you can program in assembler this is a very good choice, or else you can try their free C compiler if you know the C language. The assembler is quite simple for these low end chips though, nothing like the Z80 or the 8080 or 386 microprocessors. They only have about 32 instructions that are easy to learn. The learning curve is a little steeper for the PIC than say the Arduino though. So maybe you should read over the various choice chips and see what you might want to do. If you only need to build one or two units though then cost probably isnt an issue.
 
As I guessed in post #3, most suggestions have been to use a microcontroller for this project.
Makes sense. Ideal project for a small controller.

The only downside is the learning curve for writing code (if you have no experience of that, that can be quite daunting) and the need to buy some kit to program the microcontroller. Both fine, especially if you are intending to expand your knowledge and perhaps go on to further projects?

But, just as an exercise, I though I would sketch out the sort of thing you would need to do this in hardware. It actually works out quite cheap, and building it on stripboard, I would reckon about £5.....
That of course is for one sequencer. Up to 16 instructions ('bells' or 'gaps') and a couple of adjustments to get the bell pulse and the sequence rate to sound 'right'. All quite simple.

The downside is if you need to have several sequences pre-programmed to be available from different input buttons, without re-programming. Then you'd need one of these for each stored sequence. You can of course program this sequencer easily -- you simply adjust the switches as required - but it could get expensive if you need 10 or 20 pre programmed sequences available at the same time! :)

For that, the micro-controller option wins hands down.... it's just the extra time you might need to learn to write the specific code, and the cost of buying any programming kit required.......

Anyway, here's a sketch of my hardware idea : blockbell.jpg

It's not very pretty I'm afraid -- but it's only to illustrate the sort of circuitry that would be involved ......
 
Last edited:
The OP has some programming experience, so that's a help. No development kit is needed, They use the PICAXE to teach kids. It;s not too expensive.

Once, the "Hello World" program is done, he's half way there in terms of programmig. "Hello World" being blink an LED.

The other part, might be a little harder.

In Pseudo code it might be like this:

Main:
Initialize
Goto Idle

Idle: Wait 1000 : Go to Idle

Interrupt service:
Disable interupts
Read Switches (for now assume for of them) into unsigned integer X

B=1
If X AND B then if (X-B) <> 0 goto idle else gosub bellb1
Goto idle

B=2
If X AND B then if (X-B) <> 0 goto idle else gosub bellb2
Enable Interupts
Goto idle

B=4
If X AND B then if (X-B) <> 0 goto idle else gosub bellb2
Enable Interupts
Goto idle

B=8
If X AND B then if (X-B) <> 0 goto idle else gosub bellb2
Enable Interupts
Goto idle

Goto Idle

Bellb1:
ring bell sequence b1

Bellb2:
Ring bell sequence b2

Bellb3:
Ring bell sequence b4

Bellb4:
Ring bell sequence b8

==

so say the read value was 2
2-2 is 0 for a test of B2 therefore it would go to ring sequence B2

If the read value was 3, so two bits were set
3 and 1 is 2
2 is > 0, therefore no sequence would be executed.
Two switches changing at the same time might be tough.
Otherwise the testing order creates a priority.

So, the hard part about programming is using I2C and interrupts.

The hardware (irrespective of the PICAXE platform)
It COULD require:
A bell supply
A 5 V supply
A 3.3 V supply
worst case is also needing 3.3 to 5V logic translation.
Bell driver

I expect some wiring has to be done which will be minimal.

You might have to buy a crimper to make any needed connectors.
 
Evening everyone!

Wow, I am simply amazed at the amount of help and kindness that has been shown - thank you to everyone.

I never mentioned an EEPROM on the I2C bus, but the processor has a means of storing info for program execution. This cannot be I2C. I2C EEProms are designed to store configuration data. Often EEProms have to be erased in blocks.

Apologies, that was me getting confused!

Im of the opinion now that the micro-controller is the way to go forward, like everything its obviously a learning curve, but if I can get three different IT servers in London, Chicago and Sydney to talk together through hidden queues, and act on data transferred from each other, then Im of the conclusion I should be able to master this and 'blink' an LED!! Plus, I'm getting keener on having a play with it all! Sorting out the chips and the PCB is a different kettle of fish however, and Im feeling a bit bewildered and overwhelmed at the options and how everything fits together.

The PICAXE option has to be the logical way forward (although I've noted MikeMI's suggestion of using a parallel port, which is interesting), and I need to go an check myself the actual input voltage and watts/amps etc, used on the bell units, which i'll try and do in the next couple of days. My original thought was that we would need two identical copies of this unit to operate the two different bell sets in the building (there being one set of bells to the next signal box along the railway in each direction), but i've realised reading all the replies tonight, is that it would simply need a on-on switch adding in to the equation which sets the bell to be used, and a second output. When the bell code 'program' is run before ringing the appropriate bell sequence, it checks for which output to use, depending on the setting of the switch. I feel I'm slowly getting to grips with this!

Cost wise it needs to be as low as possible, but I'm a NOT a big believer in as cheap as possible! Could someone point me in the right direction over a list of the actual parts required tho? Looking at the PICAXE website, Im assuming it will need a 18M2 chip, to get the 14 inputs from buttons in (bell codes and bell destination switch), and a USB download cable. We can sort out the 5v supply into the electronics within the building. Does it need the PicAXE18-Project Board? You mentioned the PCA8575 (which unless I'm wrong, appears to be an ARM-based micro-controller) - which I suspect isn't needed if I'm going for a PICAXE chip. Was the UM10204 chip the I2C component you mentioned 'KeepItSimpleStupid'? Typing this I'm thinking it actually needs a blank circuit board rather than a PicAXE project board?

Sorry if all of this is blindingly simple and I'm just missing something.

Andy
 
You might find the arduino is better for you; it contains the programmer, voltage regulators, etc. (so it's ready to use out of the box). There is also more support on the web for this platform. You can get a board for ~$11 delivered (**broken link removed**), including the USB cable.

You just need to plug in the switches and a FET+diode (to drive the bell) and it's ready to play with. You can use a 4x3 or 4x4 switch matrix if it suits e.g. **broken link removed**

The language used on the Arduino is called "Wiring", but is just C++; this is more capable than a PICAXE, albeit a little harder to understand.
 
What I'm saying is to IGNORE the number of inputs on the PICAXE Chip and use the I2C bus with the PCA8575 chip: https://www.google.com/url?sa=t&rct...M-ZT5lPo1Airo5g&bvm=bv.58187178,d.cWc&cad=rja

Use this chip just for the keyboard (OK switches).

The major reason is to make the programming a whole lot easier once you master I2C.
You could make the PCA chip part of that board with switches and connect with three lines. SCA, SDA, Interrupt and Ground to the processor. The lines can't be too long. Interrupt MIGHT require a pull-up.

Use the PICAXE ports, to do the which bell and the output.

Use this https://www.proto-advantage.com/store/product_info.php?products_id=2200040 or similar assembled with machine pins and digikey p/n 568-8248-1-ND which is that chip in a
a TSSOP-24 package.

That's like $5.29 and $4.00 shipping for a $2.00 part.

That saves learning how to solder surface mount, and/or buying a stencil and buying solder paste at $20.00 per tube and a 6 month shelf life.

The SSOP-24 package is a little bigger.

Processor selection will verify compatability.

The X2 parts have a hardware interrupt function. I bought the AXE118 and the 20X2 controller separately. I havn't actually put the kit together yet.

The ULN2803 can sink 500 mA up to 50 V. Great for driving LED's.

There is a place to place an 8 pin header to access the output ports directly.

We kinda have to look at defining the I2C port and the interrupt pin. Might have to add an inverter.

Right now, I THINK the 20X2 would be fine provided you use the PCA part.

I'd need to do a bit more work in the I2C and interrupt areas.

One little piece of information is when driving a LED, you need to take into account the forward voltage of the LED which varies with the color of the LED, the suggested current, and how much voltage the driver drops.

So, typically from R=V/I, you get R must be less than (5V - 0.6 - 1.2)/20 E-3

Where 5V is the supply, 0.6 is the drop across the driver and 1.2 V is the drop across the LED.

The power dissipation of the resistor needs to be checked too from P=I*I*R. Typical resistor sizes are 1/8, 1/4, 1/2 and 1W.

ASIDE:
If these bells are expensive, we MIGHT want to consider using an injector driver IC for the bell.
 
So, I looked at the datasheets:

The PCA part needs an active low for the interrupt.
Which means you will need a pull up,rather than a pull down resistor for that pin.
Some parts support active low, others do not. If it doesn't, you have to invert the signal with an open drain inverter. 10K is probably OK.

Only certain pins/ports can be used for interrupts depending on the device.

This I2C tutorial https://www.picaxe.com/docs/axe110_i2c.pdf was hard to find.

The Dallas temperature IC might be an easy chip to initially play with.

Two pins are dedicated to I2C on each chip. I havn't found that spec yet.
SDL and SDC will need 4k7 or 4.7K or 4700 ohm resistors pulled up to +5.

Why is a k used for a decimal point? Because the dot gets lost on prints. 1m0 would be a 1 megohm resistor.
 
As I guessed in post #3, most suggestions have been to use a microcontroller for this project.
Makes sense. Ideal project for a small controller.

The only downside is the learning curve for writing code (if you have no experience of that, that can be quite daunting) and the need to buy some kit to program the microcontroller. Both fine, especially if you are intending to expand your knowledge and perhaps go on to further projects?

But, just as an exercise, I though I would sketch out the sort of thing you would need to do this in hardware. It actually works out quite cheap, and building it on stripboard, I would reckon about £5.....
That of course is for one sequencer. Up to 16 instructions ('bells' or 'gaps') and a couple of adjustments to get the bell pulse and the sequence rate to sound 'right'. All quite simple.

The downside is if you need to have several sequences pre-programmed to be available from different input buttons, without re-programming. Then you'd need one of these for each stored sequence. You can of course program this sequencer easily -- you simply adjust the switches as required - but it could get expensive if you need 10 or 20 pre programmed sequences available at the same time! :)

For that, the micro-controller option wins hands down.... it's just the extra time you might need to learn to write the specific code, and the cost of buying any programming kit required.......

Anyway, here's a sketch of my hardware idea :View attachment 83246

It's not very pretty I'm afraid -- but it's only to illustrate the sort of circuitry that would be involved ......

Hi,

Yes that's the idea if we had to do this in hardware. I had a similar idea in mind, using counters and decoders. One counter and one 1 of 8 decoder and we get 8 output steps. But i guess he isnt afraid of microcontrollers so he seems to like that route best.

Back to the uC solutions...

The PICAXE and Arduino are probably easier to learn then the PIC, but the PIC is cheaper if
there are going to be many units constructed. Startup cost is probably similar for all, but after that the PIC is the cheapest no doubt. I think the cheapest Arduino is around 15 bucks, which isnt bad for one off. A typical PIC programmer is about 30 bucks, but after that it's only 2 bucks per new circuit, so in quantity the PIC is cheaper.
Using 15 bucks as the Arduino start up cost, we have:
15+(N-1)*15=N*15 for the Arduino in quantity, and for the PIC we have:
30+(N-1)*2=30+2*N-2 for the PIC in quantity.
The break even point is then:
15*N=30+2*N-2
and simplified:
13*N=28
so we get for N:
N=28/13
which is as an approximation very close to:
N=2

So we see that the cost is almost the same after building only two circuits. But after that, the cost is reduced by 13 bucks for each circuit, so after 10 more circuits we'd save:
13*10=130 dollars USD.

The above is approximate and we can update if anyone wants to look up the more exact current prices.
 
This can be done using hardware shift registers, but thats cumbersome, another way that has been used way back is to program an eprom, the eprom is clocked by a 555/4040 binary counter, a bit of the eprom is used to stop/reset the counter, the bell code to be rung out is selected by using the address bus of the eprom, all the code would need to be the same length but you can do that by silences at the end of a shorter code.

A better way these days would be to use a microcontroller, store the codes in 2 or more bytes, call them depending on the logical state of one of the imput ports then just shift them out of one of the port pins.
Basically a word generator.
 
Although the microcontroller route is clearly a favourite option, especially for those who already have some experience ( and equipment!) with their chosen uC, from what I read the hardware 'set up' costs for a one off project (like this one) are still quite high.

The last two posts from dr pepper and KISS made me think again.......a more modern version of the EPROM and counter suggestion by dr pepper might be to use flash memory. Assuming one can find a cheap way to program one flash chip (you could buy a cheap programmer for about $35, and sell it on ebay afterwards :) ) then using that flash chip, and a few logic chips could get you a cheap unit that could easily replay thousands of 'sequences' (if necessary) for less than the cost of setting up for your uC project. And no code to write - just a few flash addresses to program.

The pages that KISS linked to show how simple (but robust) the original equipment was......doing it in hardware is sort of in keeping with that original concept :)...
Think I'll sketch it out........
 
Pic micro programmers such as the pickit 2 or 3 are about the same money, however you'd need to have basic programming skills.
If you dont allready have a programmer a hardware option might be viable, if you could get all the codes on 1 multi pole rotary switch (max of about 15) you'd only need a couple of shift register ic's and a counter.
Make-a-switch are still seen on ebay now and again, you can stack up as many poles as you need.
All this brings back memories of when I messed with baudot tone rtty.
 
I've done a very rough concept sketch (attached) and I reckon it's probably the cheapest and simplest way of doing this. Simply by adding individual switch block 'latches' as required (1 x momentary switch, 1 x resistor and 1 x 4093 on a bit of stripboard -total cost about £1), and possibly an extra couple of 74HC148 ICs to increasing the address decoding options, if needed, and you can have as many individual 'sequences' programmed into the flash memory as you need (up to the size of flash --say 512 thousand? :))
Got to be the easiest option - or at least the cheapest! The most awkward bit would be making sure you convert your binary sequence address requirements into Hex, to program into the flash!
 

Attachments

  • 1894024.jpg
    1894024.jpg
    111.9 KB · Views: 189
Sounds like you sussed it.
I think you could do without the analogue mux, however it would make programming a lot longer, probably not so good if your doing it with switches.
That circuit will probably be handy for other uses too.
Get a bag of leds for the address and data or you'll get well confused.
Also make sure the flash you use is capable of running down to static speed, flash chips usually do but make sure.

I did a similar circuit back in the early 90's, it was a baudot tty beacon, and a mate of mine did a similar thing that transmitted a rs232 preamble and the temperature from a thermocouple, they used I think a 2716 eprom, you had to erase them with ultra violet.
Showing my age now.
 
Hi All,
Sorry i've not had chance to respond the past couple of days - thanks to everyone for their help and suggestions, and well done to KISS on finding that article - sorry I should have probably linked to something like that so you guys knew what I was talking about! The machine's we have are the same as the 2nd/3rd pictures on the page (left and right) showing standard British Railways equipment.

I'm wading through the past few comments and trying to get my head around everything!

Andy
 
LeedsNorth:

I kinda thing the current is a lot higher since you used a car battery, I remember a car tape-deck/car radio i worked on needed a pulse of 10 Amps to switch.

You kind need to get a handle on the voltage and current requirements. I know that might be a tall order. I did see references to 10 V, 12V and 24 V systems for trains, but I could find nothing about bell power. That's what i was looking for.

The bell in the link basically looked like it could ring continuously rather than ding because of the contacts.
Basically like a old door bell.

I kinda gather that this might work like my old grade school, where the bell rang while the button was depressed rather than a "ding"

The mechanical "doorbell" in the house is probably 50+ years old and just dings with a little "dong" when released.

LeedsNorth
I figured I gave you enough stuff to process.

You do know how to program, but embedding programming means manipulating bits.

i2C and the use of interrupts makes things complicated in one way, but simple in others.

It simplifies the need for matrix scanning of a 4 x 4 keypad and doing software debouncing.

You already know how to program and, I think the details, are minimal. The interrupt circuit needs to use a pull up rather than pull down and the I2C circuit needs lower resistors that supplied int he kit. If the chosen PICAXE doesn't support active low interrupts and inverter would be necessary.

The I2C port and the Interrupt Pin cannot be chosen arbitrarily.

Because the outputs are not known at this point, I'm refraining from discussion about driving the outputs,

Ports usually have asymmetric source and sink capabilities. Could be 100 uA source and 25 mA sink.
Source means supply 100 uA at the logic voltage and sink means pull to ground 25 mA. Ports are not usually short circuit protected.

Ports normally default to inputs and with CMOS logic the unused inputs cannot be left floating. If they are, the chip my oscillate and get too hot and destroy itself.

I should add one other thing, the PICAXE is basically a custom programmed version of the PIC processor and they tell you which one they are. Data on the chip itself can be found on www.microchip.com. So, if you cannot find the port/bit that can be used for an interrupt in the PICAXE docs, you can look at the microchip site.

I'm waiting for questions from you and some specifications from you besides:
2 bells
16 momentary switches for 16 sequences
1 bell select switch

How is your soldering skills and could you build a small protoboard project?
Connectors are an important part.

For now, I'm thinking you might be able to use a something like a switching power supply (12 V probably) from ebay or one made by meanwell.

Possibly something like this: http://www.karlssonrobotics.com/car...tick-5v3-3v/?gclid=CO6moZuc7bsCFYEDOgodPQQAWw to supply power to the micro controller. ebay is a source as well for cheap products that can work.

We haven't talked about components that are used for spike protection etc.
 
KISS -- I can see the kind of information you are going to need, to be able to deal with the detail of the hardware needed as 'glue' for your uC solution.... and then the need to consider embedded programming - I2C - matrix keyboard - assymetric current source/ sink port options --etc -etc..

I'm beginning to be even more convinced now that a simple hardware approach is probably a better solution for this 'one off' project.
-Simple 4000 (or 74HC) series logic chips.
-An open drain output to drive a single relay - (so that the bell drive option only needs to be defined by the current capability of external relay contacts)
-An open structure for infinite (momentary) input switch additions.
-A single flash chip, to contain as many sequences as required.

There are clearly cases where uCs are really the only sensible option for a project - especially where lots of units are to be built. I'm not sure any more that this is one of those projects?.....It seems as if the extra hardware needed to be added on is almost as much as the complete project in hardware, without any uC?

Maybe the OP is beginning to wish his original post hadn't asked for 'suggestions' :) ?...
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top