I2C IO Bus

399 views
Skip to first unread message

martin...@gmail.com

unread,
Aug 17, 2018, 6:06:20 PM8/17/18
to Hermes-Lite
Hi All,
I have been using the HL2 with 50W linear with great success. Love it.

I have just made a box with MCP23008 and a ULN2003A to control the band switching on my linear. I plan on tapping the N2ADR I2C line for control.
The ULN2003A has 500mA Collector current as opposed the the filter boards ULN2003LV 100mA, so this is why I just didn't use the filter boards test points.

I am assuming that I wouldn't be the only person wanting to do this, or something similar.

Would it be a good idea to have a different I2C address for external control (as opposed to the 0x20) and have this configurable from Quisk?
The N2ADR I2C 8 bit filter selection may not suit all amplifiers etc...

Or would there be a better way to do what I have done here?

73

Martin
VK7MA

Steve Haynal

unread,
Aug 19, 2018, 10:11:29 PM8/19/18
to Hermes-Lite
Hi Martin,

Will you be using both the N2ADR and an external linear with filters? If just one or the other, then I'd just use the 0x20 address as is. 

What linear are you using? Many have a serial interface. Can you use that instead?

73,

Steve
kf7o

martin...@gmail.com

unread,
Aug 19, 2018, 11:07:42 PM8/19/18
to Hermes-Lite
Hi Steve,
I plan on using the N2ADR filter with a linear. The linear that I am using has been assembled by myself and filter selection achieved by grounding the appropriate relay.

Unfortunately the filter/band combination of the N2ADR board is not totally compatible with my linear.

I was hoping for something similar to J16 on Hermes.

I suppose I could just take out the N2ADR filter completely and go directly to the linear then use 0x20, but the filter HL2 case does make a fine little unit 😄

I should have looked back on previous posts before posting on this as I have noticed that a similar question has been asked before.

I figured that it would be a nice feature to have an extra I2C address that we could use with an mcp23008 or mcp23017 and select outputs via Quisk (or other software) similar to how we do with the filter board already..

Are there any plans for this?

Thanks Steve.

Cheers, Martin

Graeme Jury

unread,
Aug 19, 2018, 11:34:12 PM8/19/18
to herme...@googlegroups.com
Hello Martin,

A very simple solution is to use a microprocessor like a PIC or even an
Arduino Nano to take the I2C commands from the HL2 and decode them and
map them to pins to switch in the filter you want on your linear and any
other interstage filters you may have. The atmega328p chips are very RF
quiet when run from their internal 8 MHz oscillator and the outputs will
drive devices like ULN2003 directly for reasonable sink current for a
relay. The code is fairly simple and the cost is less than $5.00.

73, Graeme zl2apv

martin...@gmail.com

unread,
Aug 20, 2018, 4:05:57 AM8/20/18
to Hermes-Lite
Hi Graeme,

Thanks for your suggestion. Not a bad idea.

I have already made a little box with a mcp23008 and a ULN2003 and this works fine. I have basically copied what was on the filter board already.

The problem I have at the moment is, the filter selection on the N2ADR board does not align with my Amps filter. for example; on the N2ADR board, Band 4 filter  is 30/20m, then the Band 5 filter is 17/15m. My amp has a filter for 20/17m and the next one is 15/10m. So switching from 20m to 17m on the HL2 will change filters on the N2ADR board. If I am using the same I2C data on 0x20, I will change filters on my amp when I do not want to. 

This is basically what I use J16 for on my Anan 10.

So, having an extra I2C address, and the ability to configure it from within Quisk or other software would be nice to have feature. It can be used for other things, eg an antenna switch for example. I am sure people will find other uses too.

73
Martin
VK7MA

Graeme Jury

unread,
Aug 20, 2018, 4:26:24 AM8/20/18
to herme...@googlegroups.com
I would need the check but I think that Jim is only using 6 bits meaning that the 7th bit could be used as a flag when on band 4 to say if the filter is selected for 30M operation or 20M operation. If it was 20M then the microprocessor would map it to your 20/17 filter. The same goes for band 5 where you will either choose your 20/17 M filter or your 15/10 M filter depending on the 7th bit flag. If Jim is using the whole 7 bits then I am sure he would make the 8th bit available if it is not already. The spec allows for this and is the case for radios like piHPSDR which support Alex filters. Jim is brilliant with feature requests but I suspect that what you need is already there.

73, Graeme zl2apv
--
You received this message because you are subscribed to the Google Groups "Hermes-Lite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hermes-lite...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


martin...@gmail.com

unread,
Aug 20, 2018, 5:15:11 AM8/20/18
to Hermes-Lite
Yes!
Thanks Graeme... If we had that extra bit we would be able to work out exactly what band we are on. 
Still, it would be nice to have a additional user configurable port...
I didn't think about the HPSDR specification. I am not familiar with it. Maybe an additional I2C address / port might be outside the spec.
Thanks again!

73
Martin
VK7MA

Steve Haynal

unread,
Aug 23, 2018, 12:56:55 AM8/23/18
to Hermes-Lite
Hi Martin,

There is no plan for an additional port. I'm a QRP guy so the HL2 is really a QRP rig. I also tend to overcommit but have very limited hobby time. Just ask Alan about some past plans that have yet to materialize. So, I'm not going to commit to anything. :)

The i2c bus that the mcp23008 connects to is available to software. It is memory mapped at 0x7d and you can currently write any value/address on that bus. See ChangeBias0 and ChangeBias1 in quisk-4.1.21/hermes/quisk_hardware.py for an example of writing to this i2c bus. You can add your own extra band control for another mcp23008 at a different address to Quisk. Other may be interested if you make a nice implementation.

73,

Steve
kf7o

James Ahlstrom

unread,
Aug 23, 2018, 12:18:15 PM8/23/18
to Hermes-Lite
Hi Martin,

If you are using Quisk, you can send band data directly to your amp by modifying your hardware file. Quisk was designed with this type of control in mind. Quisk knows the band in use. So when the band changes, just send a signal to your amp. For example, add another MCP23008 in parallel with the one on the filter board, but with a different address. Then address it within Quisk as Steve suggested. Or use a serial port or even a UDP port within Quisk to connect with your amp.

Jim
N2ADR

martin...@gmail.com

unread,
Aug 23, 2018, 3:19:16 PM8/23/18
to Hermes-Lite
Thanks Jim and Steve!
Sorry Steve, I didn't mean to sound like I expected that either you or Jim do the work to implement this.
I understand that you would be very busy, especially with a project like HL2

I wasn't sure how whether the I2C communication was done via the radio firmware of SDR software. Now I know.
Thanks for pointing me in the right direction guys.

It is fantastic that you have that kind of flexibility built into Quisk!

I have been meaning to learn a bit of Python for a long time, so now I have a good incentive :)

Cheers to All

73

Martin
VK7MA

martin...@gmail.com

unread,
Aug 24, 2018, 2:17:10 AM8/24/18
to Hermes-Lite
Hi Steve,
thanks again for your help. Could you or someone else please be able to help me with this.

I was looking at the ChangeBias function in quisk_hardware.py

Looking at ;
self.pc2hermeslitewritequeue[0:5] = 0x7d,0x06,i2caddr,0x30,value1
self.WriteQueue(1)

I see from your suggestion that the bus id is 0x7d. i2caddr and value1 are obvious.

My question is, what are the 2nd and fourth parameters for? (0x06 and 0x30)?

Thanks in advance.

73

Martin
VK7MA

Steve Haynal

unread,
Aug 24, 2018, 11:25:48 AM8/24/18
to Hermes-Lite
Hi Martin,


Here the HL2 memory address for I2C2 is 0x3d as it is listed with out bit 6 set for a response. With response, the address is 0x7d. 0x06 is a cookie just to reduce the chances of random write. 0x30 is the i2c control world. This is often the address of the IC's internal register. What this control word means is defined by the datasheet of the target IC.



0x3d[31:24]I2C2 cookie, must be 0x06 to write
0x3d[23]I2C2 stop at end (0=continue, 1=stop)
0x3d[22:16]I2C2 target chip address
0x3d[15:8]I2C2 control
0x3d[7:0]I2C2 data


73,

Steve
kf7o

martin...@gmail.com

unread,
Aug 25, 2018, 12:53:38 AM8/25/18
to Hermes-Lite
Thanks for pointing me in the right direction Steve.


73

Martin
VK7MA

James Ahlstrom

unread,
Aug 26, 2018, 9:05:31 AM8/26/18
to Hermes-Lite
Hello Martin,

I have been thinking a bit more on using the I2C bus to provide band switching to your amp. Over the years I have used a variety of connections to external boxes in my shack. I have Tx filters, a homemade antenna tuner and an SWR meter to control. One of these designs used an I2C bus connection between boxes. This design failed, as the I2C bus was too sensitive to RF pickup. So I would not recommend connecting the I2C pins in the HL2 to a microcontroller in your amp. You could still add an MCP23008 chip in parallel with the filter board within the HL2, but then you must connect the eight data lines to your amp. You could use an 8-pin DIN connector but this is cumbersome.

A more general solution is to connect the amp directly to the PC and write software within the PC to provide control.  In my shack I have a control box with an Ethernet connection to my PC, and an I2C, RS-485 and a one-wire bus to connect to peripherals. The PC sends control bytes over the Ethernet connection and these are converted to bus signals for the peripherals. The I2C bus is useless as I said. The RS-485 is robust, and should be capable of signalling over a few hundred meters, enough to reach an antenna tower. The one-wire bus is useful within the shack. I never published this design because it is complicated, and never seemed to be "Finished".

For something simpler you could use a USB to serial adapter within your amp that appears as a COM port to the PC. Then write bytes to the COM port to control the amp. Personally I hate COM ports due to all the miserable hours I spent with my breakout box trying to make them work.

Another idea is to use a real USB endpoint in your amp, and use libusb to control it from the PC.

Another idea is to add a cheap 10 Mbps Ethernet chip to your amp, and connect to the PC with Ethernet.

Jim
N2ADR

martin...@gmail.com

unread,
Aug 26, 2018, 3:24:28 PM8/26/18
to Hermes-Lite
Hi Jim,
Thanks for the suggestions and advice.
I had actually thought of using hamlib along with some arduino code. This was before I learnt about the Quisk hardware file. BTW, I really love how you included a hamlib server in Quisk. Brilliant idea!
Anyway, I have managed to get everything running via I2C. I have made a shielded metal box containing an mcp32008 and uln2003a. I run shielded two core speaker cable to the box for the I2C bus. So far it works famously. I am only running a 50W amp and don't have any rf in shack issues at the moment (touch wood). However, I do have a 300W amp that I would like to use at some stage.... Having said this, band changing will be done while not transmitting, so I might get away using I2C perhaps.
Though I will investigate other methods though, as a backup plan.

Cut and pasted at the end of this post is the code I am using below from C:\Python27\Lib\site-packages\quisk\hermes (please forgive me, I am using windows for now :)). I have modified the ChangeBand function.
One thing that I have noticed is when Quisk first starts I get a timeout on WriteQueue(). Once I change a band all is good. Not sure why.
Thanks everyone for he assistance.
Nice job with Quisk too Jim. Very versatile!

73

Martin
VK7MA

def ChangeBand(self, band):
# band is a string: "60", "40", "WWV", etc.
BaseHardware.ChangeBand(self, band)
self.band = band
self.ChangeBandFilters()
self.SetTxLevel()
#Below added by VK7MA to change external amplifier band filter.
ex_i2caddr = 0x21
ex_iodir = 0x00
ex_ioreg = 0x00
ex_gpio = 0x09
hl2_bus_id = 0x7d
self.pc2hermeslitewritequeue[0:5] = hl2_bus_id,0x06,ex_i2caddr,ex_ioreg,ex_iodir
self.WriteQueue(1)
if band == "160":
ex_value = 0b00000001
elif band == "80":
ex_value = 0b0000010
elif band == "60":
ex_value = 0b0000100
elif band == "40":
ex_value = 0b0000100
elif band == "30":
ex_value = 0b0001000
elif band == "20":
ex_value = 0b0001000
elif band == "17":
ex_value = 0b0001000
elif band == "15":
ex_value = 0b0010000
elif band == "12":
ex_value = 0b0010000
elif band == "10":
ex_value = 0b0010000
else:
ex_value = 0b0000000
self.pc2hermeslitewritequeue[0:5] = hl2_bus_id,0x06,ex_i2caddr,ex_gpio,ex_value
self.WriteQueue(1)

Steve Haynal

unread,
Aug 29, 2018, 8:31:23 PM8/29/18
to Hermes-Lite
Hi Martin,

Great to hear you got this working!

73,

Steve
kf7o

martin...@gmail.com

unread,
Aug 30, 2018, 3:14:05 PM8/30/18
to Hermes-Lite
Thanks Steve,

I think I am lucky here in that I am only using a short run of shielded wire and all I2C communication is done while not TX'ing.
After all I2C was only ever meant for Intra-board communication...
What Jim was suggesting is a much more robust approach.
Anyway, it works :)

73

Martin
VK7MA
Reply all
Reply to author
Forward
0 new messages