sBitx RTC and SWR/PWR Meter |
In Farhan, VU2ESE's original build of the sBitx he found that the WM8731 codec chip and the SI5351 clock generator did not play well with each other on the same I2C bus. (I2C is a ubiquitous communications bus for microcontrollers and peripherals - its how the Raspberry Pi controls thes other modules in the sBitx). Farhan decided to implement a second I2C bus using alternate GPIO pins on the Pi - and for that he needed a software implementaion of the I2C protrocol - that is the I2C bitbang. He left the codec on the dedicated hardware bus and put the SI5351 and later the Real Time Clock and SWR/PWR meter modules on the bitbang bus.
The RTC is an Adafruit module that is a battery backed up clock for the Pi. So if you take your RTC-enabled sBitx to the field with no internet you can be confident that the time will still be correct and your FT8 QSOs will work. The SWR/PWR meter consists of a Stockton Bridge directional coupler and an ATTINY85 microcontroller to sample the forward and reflected power from the bridge and send it on the the Pi for processing.
The picture at the top of the post is the board with the RTC and ATTINY95 sitting next to the directional coupler - just prior to wiring it all up. The RTC meter worked perfectly on first power up -so far, so good.
Here is how the PWR and SWR meter sampling works. On transmit, the main sbitx program running on the Pi sends an I2C command to the ATTINY85 telling it to sample the forward and reflected power pads on the coupler and send the results back to the Pi. The ADC on the ATTINY85 should return values from 0-1023 which linearly represent 0 - 3.3V DC.
TALE OF WOE BEGINS HERE
Directional Coupler - PWR/SWR Bridge |
ATTINY85 PWR/ SWR Sensor |
To test, I put the sBitx in CW mode at max power on 40 meters which should be approximately 20 watts into a dummy load so the SWR should be 1:1. I keyed down and the power meter on the sBitx read 0 and the SWR read 1:1. Not good. I also had an external analog power meter in the circuit and it dutifully swung up to 20 watts. So power out is ok, but the sBitx power sensor is not working.
First question was - is the directional coupler working? The Stockton bridge samples the forward and reflected power and rectifies to a DC voltage from 0 to about 3 volts. I put a DC power meter on the FWD pad and keyed down - the result was 1.5V DC. Check! For good measure the REF pad measured about 120 millivolts - so pretty close to 1:1 as expected.
Next I add print statements to the sBitx code to print out the values received from the ATTINY85. This would tell me two things. First - was the ATTINY85 sending back anything - and what was it sending back. I keyed down while observing the console window - yes the ATTINY85 was sending back data on transmit, but instead of being 0-1023 the value was always -1 (all 1s binary).
Next question - is the problem in the ATTINY85 ADC or the I2C exchange. So to do that I made changes to the code in the ATTINY85 to send hard-coded values. That takes the ADC out of the equation.
On receipt of a an I2C command from the Pi an interrupt fires and the ATTINY85 samples the FWD and REF pads of the coupler and sends the data back to the Pi. The code is brief enough that I can include the whole sketch right here:
I2C Decode on Rigol DS1202 Scope |
Just an aside. This is super cool! I can see the whole protocol, the ones and zeros and acks and nacks. And the Rigol even decodes it for me. Its such a pleasure to work with good test tools - and at such reasonable prices. Just a few years ago protocol analyzers ran into the thousands of dollars. Moderns digital scopes and tools like the NanoVNA and TinySA open up a whole new world to homebrew radio enthusiasts.
St. Michaels Harbor |
No comments:
Post a Comment