Pages: 1 [2] 3   Go Down
Author Topic: would you like a program challenge?  (Read 2143 times)
0 Members and 1 Guest are viewing this topic.
Rotherham England
Offline Offline
Full Member
***
Karma: 1
Posts: 138
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

dc42,
I can use the cat 6 cable , do you think the distances would cause a problem?
Logged

Mid-Atlantic, USA
Offline Offline
God Member
*****
Karma: 30
Posts: 514
"Remember kids, the only difference between Science and screwing around is writing it down." - Adam Savage
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Having thought it over some more, I think multidrop RS485 using async serial protocol might be better because of the long cable runs, with an attiny84 at each signal. If you use Cat 5 cable (or preferably Cat 6 for its lower resistance), then depending on the power requirement of the signals, you might be able to use 1 pair for the RS422 and the remaining 3 pairs for power. The attiny84 has enough pins to connect all 4 lights, the RS485 transceiver, and the switch.

I was trying to keep it KISS with small part count, but the limitations of I2C might be biting me in the rump. Looking at a schematic used on something here at work I see that we use RS485 with a MAX1480 providing the UART translation and support circuitry to protect from shorts and static. If you want to see that part of the schematic I can check to see if I'm allowed to scan it and post it publicly. (I don't see why not as we are a research department at a University, not a commercial company...)
Logged


Rotherham England
Offline Offline
Full Member
***
Karma: 1
Posts: 138
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

that sounds as if it is getting serious. I am only volunteering to wire a set of signals for the railway.
Would sending it to me e-mail be easiest?
I think I would want to be fairly sure I had a grasp of the software program to make it happen before I spent that sort of money.

« Last Edit: April 01, 2013, 04:31:00 pm by matelot » Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Arduino Mega 2560 can use the same code as for the Arduino Uno. The I2C pins and SPI pins are at another location, so not all shields are compatible.

With that distance, use many wires or use RS485 or go wireless.
I like the idea to use Cat5 or CAt6 cable.


I would like to make a layout for the code.

Programming :
The best way to do this, is to actually create the (location of the) train in software.
The second train is just another variable.
Divide the track in parts. The switches are the dividers.
Make functions for the signals. A function for each signal. So the way the signal works is in the function. But the functions can be called in the same way.
The magic happens in a block that makes decisions on the situation at that moment. This should be written well, because it will be the hardest part to understand.

Updated according post below: To make the decisions it would be handy to have all switches in variables. So perhaps the switches should be updated a number of times per second and copied in the variables. The switches should be filtered before copied, since every wheel activates it. The variables should have the 'clean' and filtered value to make the decisions upon.
« Last Edit: April 01, 2013, 05:07:36 pm by Erdin » Logged

Rotherham England
Offline Offline
Full Member
***
Karma: 1
Posts: 138
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yea that looks about it.
One problem is that each wheel is going to be going over the sensor so it should only trigger once for each train. A delay or a ref that the train has triggered the next switch should be enough to separate the signals. I worked out <2 secs for each bogey. i.e. if switched again in less then 2 secs it is the same train.
The system as it works now is that the switches are the dividers for each section.
« Last Edit: April 01, 2013, 04:46:53 pm by matelot » Logged

Rotherham England
Offline Offline
Full Member
***
Karma: 1
Posts: 138
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the atmega 328 has 14 digital and 6 analog ports wouldn't this be enough?
I would just drive relays near the board and run the circuit from them.
Logged

London
Offline Offline
Edison Member
*
Karma: 46
Posts: 1368
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the atmega 328 has 14 digital and 6 analog ports wouldn't this be enough?
I would just drive relays near the board and run the circuit from them.

That would depend on the voltage & current needed to light the signals, remembering that the 4-aspect signals can have two lights lit at the same time.
Logged

Rotherham England
Offline Offline
Full Member
***
Karma: 1
Posts: 138
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I could use switches on the output like the 4066 quad analog switch.
Does anyone know of a similar chip that contains two way switches?
The UNO will be good enough, it has 14 digital ports, I only need 9 outputs and 5 inputs.
If I do need more at a later stage, for a reset for instance. Is it just a matter of configuring the analog ports to output 255 as high and 0 as low and to input 255 as high and 0 as low (or near to this to be sure i.e. 230 and 20).

I am starting to write a simple prog to do this. Erdin said he thought the idea was harder to explain that the programming to construct, I think he might be right. We will see.
Logged

Rotherham England
Offline Offline
Full Member
***
Karma: 1
Posts: 138
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the atmega 328 has 14 digital and 6 analog ports wouldn't this be enough?
I would just drive relays near the board and run the circuit from them.

That would depend on the voltage & current needed to light the signals, remembering that the 4-aspect signals can have two lights lit at the same time.
The second line says 'i would just drive relays near the board and run the circuit from them'  ?
Logged

Mid-Atlantic, USA
Offline Offline
God Member
*****
Karma: 30
Posts: 514
"Remember kids, the only difference between Science and screwing around is writing it down." - Adam Savage
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I could use switches on the output like the 4066 quad analog switch.
Does anyone know of a similar chip that contains two way switches?
The UNO will be good enough, it has 14 digital ports, I only need 9 outputs and 5 inputs.
If I do need more at a later stage, for a reset for instance. Is it just a matter of configuring the analog ports to output 255 as high and 0 as low and to input 255 as high and 0 as low (or near to this to be sure i.e. 230 and 20).

I am starting to write a simple prog to do this. Erdin said he thought the idea was harder to explain that the programming to construct, I think he might be right. We will see.

FYI, the analog ports of the UNO are analog only for input. They can be configured as digital I/O. See http://arduino.cc/forum/index.php?topic=22017.0
Logged


London
Offline Offline
Edison Member
*
Karma: 46
Posts: 1368
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the atmega 328 has 14 digital and 6 analog ports wouldn't this be enough?
I would just drive relays near the board and run the circuit from them.

That would depend on the voltage & current needed to light the signals, remembering that the 4-aspect signals can have two lights lit at the same time.
The second line says 'i would just drive relays near the board and run the circuit from them'  ?

That still doesn't tell me what voltage you're using. 240v AC would require expensive waterproof steel reinforced cable, if you're burying it. 12v DC, not so much, but you'll have to take into account the voltge drop over 200yds.
Logged

Rotherham England
Offline Offline
Full Member
***
Karma: 1
Posts: 138
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the atmega 328 has 14 digital and 6 analog ports wouldn't this be enough?
I would just drive relays near the board and run the circuit from them.

That would depend on the voltage & current needed to light the signals, remembering that the 4-aspect signals can have two lights lit at the same time.
The second line says 'i would just drive relays near the board and run the circuit from them'  ?

That still doesn't tell me what voltage you're using. 240v AC would require expensive waterproof steel reinforced cable, if you're burying it. 12v DC, not so much, but you'll have to take into account the voltge drop over 200yds.

Sorry Henry I don't want to sound unhelpful but the uno only needs to run relays or even opto isolators such as

http://www.ebay.co.uk/itm/280947061304

so the issue of power for the LED's is not important.
The whole circuit runs on 24 v dc but the board for the uno chip will have a 5v regulator , a 7805 , running it.
The present system is running the LED's at the moment but with boards in each signal box providing the correct switching. I want to run the circuit from a program chip and send just wires to each head.
That way I can also run an indication board at the signal box, Which I can't do at present.
I will take into account the voltage drop and change the inline resistors to adjust the brightness.
I do appreciate you keeping with me, thanks.

« Last Edit: April 03, 2013, 07:09:42 pm by matelot » Logged

Rotherham England
Offline Offline
Full Member
***
Karma: 1
Posts: 138
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

FYI, the analog ports of the UNO are analog only for input. They can be configured as digital I/O. See http://arduino.cc/forum/index.php?topic=22017.0

Thanks Sembazuru that is exactly what I wanted I now have 6 more ports.
Logged

London
Offline Offline
Edison Member
*
Karma: 46
Posts: 1368
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry Henry I don't want to sound unhelpful but the uno only needs to run relays or even opto isolators such as

http://www.ebay.co.uk/itm/280947061304

Understood from earlier post.
Quote
so the issue of power for the LED's is not important.

This is the first time you've mentioned that the signals are LEDs, hence my confusion.

Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 223
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The whole circuit runs on 24 v dc but the board for the uno chip will have a 5v regulator , a 7805 , running it.
The present system is running the LED's at the moment but with boards in each signal box providing the correct switching. I want to run the circuit from a program chip and send just wires to each head.
That way I can also run an indication board at the signal box, Which I can't do at present.

Then I think the simplest solution is to run a separate Cat5e cable from the control unit to each signal. 100m reels of outdoor-use Cat5e cable are not very expensive. Each cable has 8 conductors, which is more than enough for 4 lights, 1 switch and ground (I suggest you use the 2 spare conductors as additional grounds). The final 2 signals have 5 lights and 1 switch between them, so you could manage with a single cable run for both.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Pages: 1 [2] 3   Go Up
Jump to: