Arduino USB interface for sensor feedback to Rocrail

rozsaheg
Posts: 35
Joined: 10.06.2015, 21:02

Re: Arduino USB interface for sensor feedback to Rocrail

Post by rozsaheg » 28.12.2015, 12:08

Manos,

1. Be sure the VCS-1 is on a different com port and this is the default CS.
2. If not only the grounded (or changed) pin reporting, we have to find what cause this. Normally the MEGA has to send only one CAN type of message.
3. If you try UNO, change the variable "a" to "1" in the skeleton_ultimate program.

Perhaps you mix virtual and real things in your test. If you send the *.trc file to me in private, I can study the problem more deeply.

Regards

Laszlo

sv1iw
Posts: 46
Joined: 16.09.2014, 21:40

Re: Arduino USB interface for sensor feedback to Rocrail

Post by sv1iw » 28.12.2015, 23:32

Hi Lazlo
Today I did another test using my laptop instead of my desktop. The behavior is exactly as described on my previous message...
Regards Manos SV1IW

Send me a message to sv1iw@raag.org I will reply to this with my .trc file. Perhaps you are right mixing virtual and real things makes rr confused...

sv1iw
Posts: 46
Joined: 16.09.2014, 21:40

Re: Arduino USB interface for sensor feedback to Rocrail

Post by sv1iw » 24.01.2016, 00:07

Just to have a final comment since the system plays well now and I expect others to try. My issues were mostly on the block parameters, and once solved with Laszlo's help sensors behave normally,

Manos SV1IW

rozsaheg
Posts: 35
Joined: 10.06.2015, 21:02

Re: Arduino USB interface for sensor feedback to Rocrail

Post by rozsaheg » 11.12.2016, 18:57

If you curious how this interface works in real environment, you can follow this link (http://forum.rocrail.net/viewtopic.php?f=11&t=12667), where Manos shares information and pictures on his real plan. If you have question or suggestion, need help, just ask us.
Laszlo
Last edited by rozsaheg on 23.01.2017, 19:22, edited 3 times in total.

rozsaheg
Posts: 35
Joined: 10.06.2015, 21:02

Re: Arduino USB interface for sensor feedback to Rocrail

Post by rozsaheg » 19.01.2017, 11:48

Hi Guys,
Is there anybody who has tested this solution ? If yes, please share the experience with us.
Thanks
Laszlo

anam
Posts: 65
Joined: 25.02.2008, 21:41
Location: Santhia' - ITALY

Re: Arduino USB interface for sensor feedback to Rocrail

Post by anam » 22.01.2017, 21:08

Hello Laszlo,

I made same tests mega+pc+rocrail and everythings worked well. In next weeks I will try to connect my layout's real sensor (current sensor).
By the way, I have a question. How can we link two or more mega?
Thanks.
Daniel

p.s. : I m not able to follow the link you suggest in previous post. "viewtopic.php?f=11&t=12667"

rozsaheg
Posts: 35
Joined: 10.06.2015, 21:02

Re: Arduino USB interface for sensor feedback to Rocrail

Post by rozsaheg » 23.01.2017, 19:51

Hi Daniel,
You can find the solution on the following link, how to connect more mega. The secret weapon is the I2C protocol. If you need I can help to modify the "skeleton ultimate" program for more mega.
http://www.instructables.com/id/I2C-between-Arduinos/
I have repaired the the bad link (http://forum.rocrail.net/viewtopic.php?f=11&t=12667)
Regards
Laszlo

rozsaheg
Posts: 35
Joined: 10.06.2015, 21:02

Re: Arduino USB interface for sensor feedback to Rocrail

Post by rozsaheg » 11.02.2017, 12:41

I have received a PM from Jens and I would answer on public way. Perhaps it is interest to others as well.

"Hi Lazlo,
since a few days I'm using your tool. It works like a charme :-) Because of the need for many Pins I'd like to ask if it is possible to use the Analog Pins A0-A15 as well ?? How should I Change the script to use These Pins??
THX
Jens"

First of all the answer is "yes". I will explain the solution with a little bit more details, because probably not everybody familiar with this possibility. You can reference to analog pins with numbers as well. Actually the analog pins follow the digital pins in the table. (see https://docs.google.com/spreadsheets/d/ ... /pub?gid=0). The "A0" is equivalent with "54", the "A1"with "55" and so on .. Our task only to increase the for cycle with 2*8.

Original program initialization
int a=6; //max 6; number of virtual sensor blocks
int b=8; //max 8; virtual sensor block's port
int sensors[7]; // status "matrix"
byte tx_msg[13]; // CAN message to transmit

Modified rows for analog pins usage
int a=8; //max 8; number of virtual sensor blocks including analog pins
int sensors[9]; // status "matrix"

That is all. For your convenience I have attached the modified program
skeleton_ultimate1.zip
Feel free for any questions or suggestions.

Laszlo
You do not have the required permissions to view the files attached to this post.

jensgulow
Posts: 54
Joined: 26.10.2015, 15:01
Location: Leipzig / Germany

Re: Arduino USB interface for sensor feedback to Rocrail

Post by jensgulow » 12.02.2017, 01:02

Hi,


another question ..... the part with the sensors is working fine :) .

Is it possible to create a communication via USB in the opposite direction (get Infos from Rocrail about turnout Status for managing servos via the arduino) :?: ???

rozsaheg
Posts: 35
Joined: 10.06.2015, 21:02

Re: Arduino USB interface for sensor feedback to Rocrail

Post by rozsaheg » 12.02.2017, 10:56

Hi Jens,
The opposite communication is possible, nothing special. You can control turnouts or signals, gates and so on with Rocrail via USB.
I will release the solution for turnouts in some days.
Regards
Laszlo

jensgulow
Posts: 54
Joined: 26.10.2015, 15:01
Location: Leipzig / Germany

Re: Arduino USB interface for sensor feedback to Rocrail

Post by jensgulow » 12.02.2017, 11:58

Great .... :D

rozsaheg
Posts: 35
Joined: 10.06.2015, 21:02

Re: Arduino USB interface for sensor feedback to Rocrail

Post by rozsaheg » 16.02.2017, 19:07

Jens, you can find the solution in my new topic http://forum.rocrail.net/viewtopic.php?f=11&t=13329
Laszlo

Antogar
Posts: 32
Joined: 11.02.2017, 23:10

Re: Arduino USB interface for sensor feedback to Rocrail

Post by Antogar » 19.02.2017, 19:12

rozsaheg wrote:Hi Guys,
Is there anybody who has tested this solution ? If yes, please share the experience with us.
Thanks
Laszlo
Hi Lazlo,

I am trying to use your code with Arduino UNO and Rocrail running on a Linux pc without connection to track layout. I am also new with RocRail... :oops:

The code was modified with a=1, so I have just 8 pin (D4 to D11) for feedback. After the upload to Arduino, the code seems working well: as far as I connect a wire to one of the pin, the TX led start flashing indicating that the transmission is on going.
To test the connection I made a siple track layout with 8 sensors and I associated them to the address 1-8 of the MCS2 controller, called "Arduino"

I have problems in configuring in RocRail:
1. with linux the com ports are called ttyxxx, in my case /dev/ttyACM0. Is this the correct indication to insert in controller configuration?
2. what are the other parameters:
Image

3. what are the parameters to configure the sensors ? just the interface ID, the bus and address ?
Image

4. I see this window in RocRail for sensor monitoring but nothing changes if I connect to ground the Arduino pins, even the transmission happens from Arduiono
Image

Thank you in advance!

Bye :)
Antonino

Antogar
Posts: 32
Joined: 11.02.2017, 23:10

Re: Arduino USB interface for sensor feedback to Rocrail

Post by Antogar » 19.02.2017, 19:46

Hi

I solved by myself.... now works :)

ciao

Liviu M
Posts: 942
Joined: 03.12.2011, 20:44

Re: Arduino USB interface for sensor feedback to Rocrail

Post by Liviu M » 19.02.2017, 19:50

Hi Antogar,

please post your solution for the next user with the same problem.

Thanks,
Liviu

Post Reply

Return to “DIY Hardware”