This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Slave PWM sync with master clock

Is there a way to access the lower level clock which a connected slave uses to stay in sync with the master. We want to use this to keep our PWM in sync. We are looking for 8 connected slaves to be in sync and generated a PWM signal. What is the best way to implement this?

Thank you,

Parents
  • Hi

    There is no way to get hold of the base time of the BLE stack if that is what you are asking, but neither do I think this would be of much help. First of it will be different from link to link, and secondly the accuracy will change over time because of the inaccuracies of the system clock.
    As an example, even with a relatively accurate external 20ppm 32kHz clock you would get up to 20us drift per second, which would quickly add up to more than 100us variance from link to link.

    I think the best way to do this is to send a proprietary sync packet using the micro ESB library, as this library allows you much more control of the packet timing, and allows you to update the payload for each packet to reflect the current time.

    One of the devices in the network can send a sync packet and the other devices can adjust their timers based on that.

    For this to work with the SoftDevice you will have to request timeslots from the SoftDevice in which to run the ESB protocol, as described in the following blog: Running micro-ESB concurrently with BLE

    Best regards
    Torbjørn

  • The packet transmission will be synchronized between the master and slave, that is correct, but that doesn't necessarily mean that the timer value will be the same. Nor does it solve the problem of synchronizing the various slave links, which will run at different times.

    There is no example for the time sync, but the principle is pretty straight forward: Send a time beacon from the central device, and make sure to disable the retransmit feature to make sure that you only try once to send each packet. You should expect some packet loss in the receiver, so you should probably send multiple time sync packets, updating the timer value in the payload for each one. Each time a packet is received by the RX you read the timer value from the payload and use that to adjust the local timer.

Reply
  • The packet transmission will be synchronized between the master and slave, that is correct, but that doesn't necessarily mean that the timer value will be the same. Nor does it solve the problem of synchronizing the various slave links, which will run at different times.

    There is no example for the time sync, but the principle is pretty straight forward: Send a time beacon from the central device, and make sure to disable the retransmit feature to make sure that you only try once to send each packet. You should expect some packet loss in the receiver, so you should probably send multiple time sync packets, updating the timer value in the payload for each one. Each time a packet is received by the RX you read the timer value from the payload and use that to adjust the local timer.

Children
No Data
Related