User Tools

Site Tools


info:sonos_api_for_seeburg

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
info:sonos_api_for_seeburg [2023/11/12 08:29] 192.168.1.71info:sonos_api_for_seeburg [2023/11/12 08:35] (current) 192.168.1.71
Line 1: Line 1:
 +===== Sonos API for Seeburg =====
 +This website is no longer available.
 +
 +Having solved the electronics problem I developed a small Python program to handle the decoding logic and the communication with the home media system.
 +
 +The main loop of the program polls the GPIO pin which is connected to the voltage regulator.  When there is a pulse, the GPIO pin registers as “true”.  The pseudo-code looks like this:
 +
 +<code>
 +Wait for a pulse
 +
 +When a pulse is detected, count the pulses in the pulse train
 +
 +a) Count the pulses before the “gap” and store this as the selection number
 +
 +b) Count the pulses after the “gap” and store this as the selection letter
 +
 +Play the song corresponding to that selection
 +
 +Go back to the start
 +</code>
 +
 +It should be simple, but there are a couple of small complications to overcome.   The first complication is that the electro-mechanical nature of the wallbox creates occasional voltage spikes (from relays etc.) that are not part of a pulse train.  For example a short spike is created  when an inserted coin generates a credit, and another spike is seen when the rotor arm starts to move.  These could lead to decoding errors if they are interpreted as part of the pulse train.  The software needs to identify and ignore these.
 +
 +The second complication is that the square waves of the pulses (from the voltage regulator) have short gaps between them when the GPIO will read False.  We need to ignore these also.  
 +
 +To solve both of these issues, I wrote a short function that allowed the logic to ignore short gaps and spikes.  It checks that a “change of state” from true to false or vice versa lasts a certain minimum amount of time.  Ideally this would have been based on the RPi timer, but I found that the latency of using the time object introduced too much error and in the end I opted for a simple iterating loop and the right number of loops was found by trial and error.  It's not pretty and I would welcome any other ideas from people about this.  Possibly rewriting in a compiled language would allow us to do this more elegantly.  There is a full list of the actual Python code on the resources page.
 +
 +The logic now runs like this:
 +
 +<code>
 +Wait for a pulse
 +
 +When a pulse is detected, check that it is long enough to be a proper pulse, if it is very short ignore it
 +
 +If it is a proper pulse then start counting the pulse train and don’t stop until there has been a gap of more than X seconds
 +
 +Whenever the GPIO pin state changes check that the change is long enough to correspond to a signal pulse or gap. If it is very short ignore it
 +
 +Count the pulses before the big gap and store this as the selection number
 +
 +Then count the pulses after the big gap and store this as the selection letter
 +
 +Play the song corresponding to that selection
 +
 +Go back to the start
 +</code>
 +
 +I wrote several debugging programs which output information to the terminal to show data about time between pulses and final calculation of the selection so that I could be sure that it was working and to fine tune the function that ignores the spikes and short gaps.  Here is a video showing one of these programs working.
 +
 Now we have to get the Raspberry Pi to communicate with the home music network.  In my case this was a SONOS system, but this approach will work with any home music network that supports the open UPnP protocol.  \\ Now we have to get the Raspberry Pi to communicate with the home music network.  In my case this was a SONOS system, but this approach will work with any home music network that supports the open UPnP protocol.  \\
  
info/sonos_api_for_seeburg.1699795750.txt.gz · Last modified: 2023/11/12 08:29 by 192.168.1.71