Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Triggering TimeSync to end devices


  • I am trying to figure out the easiest way to send a command once a day to trigger a time update on my arduino devices. I can manually do it and now I want to automate the write to a modbus register. I created a scheduled event via CRON and not sure how it can be used to trigger a softpoint to create a time stamp and write it to a setable modbus register.


  • Check out event handlers. Find your scheduled event and then use a set point handler to set the value of your modbus point.


  • What I ended up doing was setting a softpoint to contain the epoch in local time based on a CRON pattern. e.g. every 10 seconds. I can't think of another way to get the current timestamp to use in the event handler.

    I used the schedule to fire once a day to feed an event to set the time into the given setpoint to be sent to the slave.

    What I wanted was to use the softpoint to do it. e.g. CRON once a day, then set the the time for all slave devices. e.g. p.value = timestamp. Alas, this cannot be done at the softpoint level. It seems I have to create a schedule time event for each slave, then a event handler for each schedule event.

    Another option is that I can change the arduino code to deal with slave ID of 0 and implement a broadcast write. Will Mango deal with broadcasts and if it does what doe it expect back?


  • Modbus4J, the underlying modbus implementation, supports broadcasts, but not Mango itself.


  • The Mango datapoint entry UI is set to accept a slave address of 1-240 so if I understand your reply, Mango cannot support modbus broadcast without changes to the application layer of Mango?

    I suppose hack my ardiunos to take address 1 as a "broadcast" rather than the standard 0 address and hardcode only one device to send a response back.


  • @chrapchp - I was wondering what modbus library you use for your Arduino. I've been using this one:

    http://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slave

    It works OK to get data, but when I try to set data I get an error message. Probably the modbus command used isn't supported by the Arduino library. Looks like you use one that does.

    (sorry for being a bit off-topic here)


  • Update: the slave side of Modbus4J supported broadcasts, but there were problems on the master side. The library has been updated to fully support broadcasts now. Changed code has been checked into the CVS repo.


  • I used that one as well. It does not have a modbus function 6 which is what is sent out from Mango. I hacked a function 6 in the arduino and I can write to it now. It is not pretty and plan on create a class someday to abstract the communication layer.


  • OK, thanks for the tip. I also added function 6 and I can now set points too :) I also made the whole thing into a separated Arduino library (which was something that needed to be done anyway).

    I also added code to make it easy to check which registers were changed by the master.

    I'll ask jpmzometa if he wants to include the changes.

    (Again, sorry for being off topic here)


  • Great. It is nice when progress is made.

    I transfer write registers to separate variables. If I need feeback of a write I use seperate read registers. That way I know my embedded code is performing correctly.

    I will be hacking a broadcast as well for my nightly time syncs. Slave ID of 0 is not allowed from the ui. I will pick one arduino to respond to an address 1 request while the others are passive and used that as my broadcast address.


  • Hello.

    How can I send time and date to all arduino slaves with mango and modbus rtu?

    Is it possible?

    Thanks


  • You can't set the broadcast address of 0 on the mango UI. If you want to work with the existing code base, select another address say 1 as the "broadcast" address. Not sure what you have for modbus implementation on the arduino side but probably is minimalist and probably does not have broadcast handling capabilities. I am assuming you got what was floating around for free. I had to add modbus functions on the arduino side to do what I want. I did not do broadcast functionality but it should not be too hard to implement.

    I would change the code to handle a "broadcast" address and have only one device respond to a request to the master and the others are passive listeners. That way only one entry is required on the Mango side along with a CRON event to trigger write the timestamp.

    Otherwise you could probably use Mango events to fire off to write the date/time as a unix epoch timestamp or what ever format you want to send to registers in Modbus and manually configure a date/time point for each device. That would emulate a broadcast.

    Not sure if that helps.


  • I'm using this library in arduino.
    http://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slave
    It doesn't implement broadcast messages. I was talking with the writer but he is busy to add that feature.

    He says that there is no reply from slaves for a broadcast message.

    It's very interesting to add broadcasting to the library but my C++ knowledge isn't good enough.


  • That is the one I used and modified on my own for my own consumption last year. Even if you add a broadcast in the arduino code, the UI on the Mango side won't let you add a broadcast address of 0. So elegant changes or a hacks needs to be made, hence my suggestions.


  • The writer of the library told me to make myself the changes and add them to the official release.
    If you send the changes he will add them in the web page.

    About Mango modifications... Is there any answer from Serotonin?


  • @mlohbihler said:

    Update: the slave side of Modbus4J supported broadcasts, but there were problems on the master side. The library has been updated to fully support broadcasts now. Changed code has been checked into the CVS repo.

    Modbus4J works with broadcast, Mango not. Am I right?


  • There are several options presented in thread. If you don't feel comfortable with the C++ or looking at the Mango code, as stated earlier you ca create an event to write to each of the registers in your arduiono with a UNIX epoch timestamp from Mango.


  • Yes. Send time to every slave is the way I was using in the pass. I was wandering a better way to do it.


  • It gets difficult if you don't feel comfortable changing the modus C++ code on the arduino side. The code is easy to follow and change.


  • have you made the changes in the arduino library?