Mobile RCP Rocmouse

Dagnall
Posts: 237
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 27.04.2018, 13:56

There is a simple video of the switch tool in operation here:
https://youtu.be/kwU2oWAyCBs
You may need to pause to see the captions, but it shows the tool in operation.
UNTITLED.jpg

Dagnall
Posts: 237
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 27.04.2018, 15:53

One thing that is cropping up is that the Broker is repeatedly sending the response(s) to the lcprops message.
My code has no way of discriminating these messages so is getting overwhelmed with locos in its list..

A client\info monitor shows the lc data is being repeatedly sent, presumably by the broker..
I need to sort this if the throttle is to be any use. Also, the same thing affects the SW tool.

Whichever response was last sent keeps repeating..

I need some innocuous message that will switch off the brokers "repeat last message" functionality

Dagnall
Posts: 237
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 27.04.2018, 17:42

Rob, I may have sorted the repeated response message issue,
but can you help me with an issue abouts lights (f0).
I would like to control these, but they seem to respond differently to other functions.
My code

Code: Select all

<fn id=\"%s\" f%d=\"true\"  />"  
with %s= the loco Id and %d is the function number works well.. (except for F0).
but what I thought was equivalent for f0...

Code: Select all

"<lc id=\"%s\"  f0=\"false\"   />
... does not alter the lights. Do they have a special "number"? or is there some special command in the client to do this.

I'm trying to sort out a few final bugs as Jan is setting up a demo for his train group somewhere in Holland and we are PM'ing issues and bugs......

rjversluis
Site Admin
Posts: 38719
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Mobile Rocmouse

Post by rjversluis » 28.04.2018, 06:38

The lights are mostly part of the speed commands:

Code: Select all

<lc id="x" fn="true"/>

Dagnall
Posts: 237
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 28.04.2018, 13:46

Rob, Thanks again!.
I have it working now..
For my records, I found the fn command in 46.25.1. lc (n) of http://rocrail.net/software/rocrail-sna ... ml#command
I was confused and thought I needed to control it with an f0 commands which appear under section 37.0 fn (1).

Anyway, its working now and many thanks. :thumb_up:

My very simple throttle experiment can now select any loco on the layout and change its speed, pulse functions 1-8 AND now turn on or off its lights.

:rr_for_ever:

Dagnall

:!: I do wonder if this tool might be a bit "dangerous" in a club environment? I would like to understand better the "handoff protocol" and message sequences used with the Pi04 system if you can point me to a detailed explanation? :?:

Dagnall
Posts: 237
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 01.05.2018, 13:30

I thought you might like to see the "Final" device: (The case is a work in progress)
The five way button is used to scroll through the menu (right) select speeds /locos etc (up and down) etc.
IMG_2156.jpg
Home Screen once Router and Broker have been found
It works with up to about 100 locos. It is functionally limited mainly by the number of messages that the Broker can buffer.
If you have more than 100 locos I suggest that you follow Robs advice earlier in this thread and look at alternative throttles!! :wink:
IMG_2157.jpg
Select Loco Screen
The speeds are: 0=Stop, 1=V_min, 2=V_mid, 3=V_Cru, 4= V_max.
IMG_2158.jpg
Choose speed (uses the Speeds from the Loco table)
The code can select Functions f1-f8, and will send a momentary command to turn them on (then off after a short delay) by pressing the select button.
IMG_2159.jpg
Press to operate Fn x momentarily..
Function "0" is a Toggle to switch lights on or off.
IMG_2160.jpg
Fn"0" is special and turns on or off the lights.
Many thanks Rob for adding the lcprops command...
:rr_for_ever:

If you would like to make one the code is here: https://github.com/dagnall53/RocClientThrottle

Cheers :beer:
Dagnall

rjversluis
Site Admin
Posts: 38719
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Mobile Rocmouse

Post by rjversluis » 01.05.2018, 14:18

Hi Dagnall,

the display looks very small on your pictures.
But you did do a good job. ;)

Dagnall
Posts: 237
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 01.05.2018, 15:52

rjversluis wrote:Hi Dagnall,

the display looks very small on your pictures.
But you did do a good job. ;)
Thanks, It would probably be easy to modify for a much larger display, but that was the size that comes on these cheap boards!.
As you said, earlier, there are already other options with better cases and displays.
And besides, one reason for working on this was to understand the client server operation, so I could get the SwitchTool working.

The SwitchTool is actually slightly more complex, because it uses both the Client server protocols and also the Rocnet protocols.
I do have it working now. It does not have any fancy graphics, so no photos, and besides, the writing on the screen is very small!! :wink:
But it is good to be able to walk to a turnout in the garden and switch it or test and alter its position settings!

All the best
Dagnall

RedTrain
Posts: 675
Joined: 13.10.2012, 19:21
Location: Uetikon am See, Schweiz
Contact:

Re: Mobile Rocmouse

Post by RedTrain » 01.05.2018, 17:58

Hi Dagnall

This thing looks really cool! :thumb_up:
How would you power it and put a case to it - as a mobile Rocmouse? :)

Dagnall
Posts: 237
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 01.05.2018, 18:30

RedTrain wrote:Hi Dagnall

This thing looks really cool! :thumb_up:
How would you power it and put a case to it - as a mobile Rocmouse? :)
Power it: .. Simple...
It has a 18650 LIPO holder on the "back" of the board, and a charger built in so the battery it can be recharged from the USB. :D

Case: Not so simple..
I have designed a simple 3D printed box like case and will put it on thingyverse, but at the moment its not accurate enough..
IMG_2161.JPG
First printed case shown with two Wemos Boards, so you can see both sides of the wemos boards...
Cheers
Dagnall

RedTrain
Posts: 675
Joined: 13.10.2012, 19:21
Location: Uetikon am See, Schweiz
Contact:

Re: Mobile Rocmouse

Post by RedTrain » 02.05.2018, 19:22

Wow!! - Let us know, once it's there :D
Would be nice to have your user page then amended with a little "how-to-for-the-not-so-literate" - I would be tempted to try building a couple of those... :P

Dagnall
Posts: 237
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 07.05.2018, 14:48

I have published the stl files to allow you to make the casing https://www.thingiverse.com/thing:2897872
My painting leaves a lot to be desired, but the cases are "ok".
There is now a "#define" in the code to allow the addition of the rotary switch, which , if used, replicates the up and down functions of the 5 way switch in a more ergonomic way.
I would do a video of it running the garden, but my garden railway network has gone down and I need some spare parts. :mad:

I have, however, added some more information on my User pages http://wiki.rocrail.net/doku.php?id=use ... clienttool
Attachments
IMG_2164s.jpg

drblack
Posts: 58
Joined: 10.05.2008, 13:02
Location: Quickborn, S-H

Re: Mobile Rocmouse

Post by drblack » 08.11.2018, 21:38

Hi Dagnall,

I came across your fabulous little throttle and ordered the WeMos Display kit.
But somehow I got stuck when I tried to get the loco infos:

Code: Select all

-----------------------------------------------------------
             ESP8266 Rocrail Client 'Throttle'    
-------------------- limit 30 locos ------------------------
                    revision:3
-----------------------------------------------------------
Trying to connect to {Steckdosenrouter} .
--Connected--

---------------------------Connected-----------------------
 Connected to SSID:XXXXX  IP:192.168.178.116
 Mosquitto will first try to connect to:192.168.178.110
-----------MQTT NOW setup ----------------
--- Setting OTA Hostname <RC<SwitchTool>> -------------
------------------------------------------------------
@<00:00:00s>: Attempting MQTT (re)connection. Attempt #0
 trying:192.168.178.110  Switch Tool:116  


 *Debug Message: Time not synchronised yet  Throttle:  Msg:Switch Tool:116 Connected at:0.0.178.116  

 *Debug Message:<03:35:20s>  Throttle:  Msg: IPaddr .116  Time Synchronised.   
sending Loco info request   <model cmd="lcprops" />

 *Debug Message:<15:21:20s>  Throttle:  Msg: IPaddr .116  Time Synchronised.   

 *Debug Message:<15:22:20s>  Throttle:  Msg: IPaddr .116  Time Synchronised.   
sending Loco info request   <model cmd="lcprops" />
But when I do :

Code: Select all

mosquitto_sub -t rocrail/service/info
on the pi the mqtt and rocrail server is running on everything seems as expected when I press the button.

Do you have any idea, what I do wrong? There seem to be different kinds of MQTT libs for arduino which one did you use?

Thanks,

Henning

Dagnall
Posts: 237
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 10.11.2018, 11:31

Henning.
Sorry you are having problems.. I see you have forked the code to make changes. A very good idea!.

I have not got my railway/ rocrail setup working at the moment, but will try to make some initial suggestions based on memory.. I hope you can work from these.
I am pretty certain I used https://pubsubclient.knolleary.net/ for the MQTT library, and a recent Rocrail, as the older ones did not support LCprops, and also sent the response as a single huge chunk with all the locos, which the MQTT library simply rejected. The revised code rob uses sends the response data as multiple "single loco" chunks which are small enough for MQTT to accept.

I see you have your MQTT broker running on 110. The wording "Attempting MQTT (re)connection. Attempt #0" could be better as it might be misunderstood!, It was originally there for the code that checked sequentially for the MQTT broker.

can you also check that the MQTT Rocrail service is running correctly? Do you have other nodes working such as turnouts or sensors? There are some troubleshooting ideas here https://wiki.rocrail.net/doku.php?id=us ... leshooting

I recall that I also used a MQTT monitor to show the Loco info when I was developing this, and this bat file to simulate what the Tool would do to send the LCprops command: (change the MQTT address of course!)

Code: Select all

TITLE SW Pub test
CD C:\\
cd mosquitto
mosquitto_pub -h 192.168.0.21 -p 1883 -t rocrail/service/client -m "<model cmd=\"lcprops\"  />" -q 1 
I think that you need to monitor the Service/client to see the response with something like this bat file. (This was how I discovered that the code was originally sending too much data in each message for the MQTT library to accept. )

Code: Select all

TITLE Rocrail Client Monitor 
CD C:\\
cd mosquitto
mosquitto_sub -h 192.168.0.21 -t rocrail/service/client -q 1
Please let me know if this helps, I will try to answer more when my system is back up and running.

I would also say that I have gone "off" this idea, as the way you have to hold the module means you cover the antenna and so the range you get is very poor.
What I would like to do next is to understand how the Pi throttle https://wiki.rocrail.net/doku.php?id=gca-pi04-enRob uses actually works, (what commands are sent etc) as I think this is a better approach than my "brute force" throttle. If you have any ideas or can experiment, please let me know!!

Dagnall

drblack
Posts: 58
Joined: 10.05.2008, 13:02
Location: Quickborn, S-H

Re: Mobile Rocmouse

Post by drblack » 17.11.2018, 22:58

Hi Dagnall,

thanks for your reply.
To me it seems that the mqtt message is not properly received by the ESP8266. Rocrail sends data as requested but there is nothing in the logs showing up.
I set up a clean arduino to make sure that there is nothing else in the background. But still the same.
I am running out of ideas...
If you have your system running at certain point, maybe we can double check versions of libs etc.

Best,

Henning

Post Reply

Return to “DIY Hardware”