To be able to run the code for the Automatic Magnetic Loop Tuner, that was written for a Teensy 3.2, on a Teensy 4.0 the following changes needed to be done. First I started by changing the version to version 5. It would have been cool to use version 4.0, but that version already existed 😉 So the next best thing was version 5, as a tiny reference to the 5 in my callsign.
ML_v500
The LiquidCristalFast.h library was changed to LiquidCristal.h
The resolution of the ADC was set from 12 (Teensy 3.2) to 10 (Teensy 4.0)
Analogue pins A10 and A12 were assigned.
ML.h
Assigning the pins to the input and output. Just as in the Teensy 3.2 version, Pfwd is assigned to pin A10 but Pref is assigned to pin A12. In the Teensy 4.0 pin A11 is also ADC0 and we need both a ADC0 and a ADC1, not twice ADC0.
ML_PSWR
Used analogeSyncRead() instead of analogeSynchronizedRead()
ML_TRX
For Icom radio’s set the UART output to opendrain=true and for all the others to opendrain=false
ML__Switches_and_Stepper
As the ADC only has 10 bit (1024) compared to 12 bit (4096), we had to divide all values by 4 to know which button is pressed.
Github
The source code is available on Github: https://github.com/ON5IA/ML_v500
Disclaimer
Currently the code works when the Automatic Magnetic Loop Tuner is connected to an Icom IC-7300. Please be aware the Teensy 4.0 is not 5V tolerant, so make sure you never exceed 3,3V on your inputs.
Hi,
Thanks for porting Loftur’s magnetic loop tuner firmware for teensy 4.0.
I had fix an issue which I already had in Lofturs’s code.
I had to comment out the line
lcd.createChar(0,0); in ML_v500.ino
According to Arduino reference: “ When referencing custom character “0”, if it is not in a variable, you need to cast it as a byte, otherwise the compiler throws an error.”
With tis line in the code there were no visible characters on the lcd screen.
After removing or commenting out this line the code works as expected.
Since there are no custom characters in the firmware, this line can be removed without consequences.
Kind regards,
Béla / HB9HEY
Hi Béla, thanks for letting me know. I’ve updated the code and pushed it to Github.
I’ve also noticed some other changes I can do, but that will be done later.
73!
For me, the code is not compiling…its stopped compiling quoting error Status 1
Can you provide the schematic for the ML using Teensy 4.0,
or please what are the changes to be made for the schematic for using Teensy 4.0
Hi Ameer,
Make sure you are using the right settings in Arduino to compile (correct board, cpu speed, etc…) The code should compile, as it does on my pc and on several other OM’s pc…
I’m currently bussy updating the schematic, most important changes are in the protection of the Teensy 4.0 input pins. I’m doing this with BAT545 Schottky Barrier Diodes.
I’ll keep you posted.
hi Frederik,
thank you for porting the code to use with Teensy 4.0 while T3.2 is no longer available. A very valuable work!
I use one of your PCBs with the pins for A10 and A11 under the Teensy 3.2 . Now I want to “free” the T3.2 for another (older) project and replace it with a Teensy 4.0.
So what is to do to protect the inputs from 5V used for the display (the data lines are bidirectional!)? First idea was a levelshifter, but is it really needed? I found no line at the code, where an answer from the display is attended. Am I right?
What to do with the encoder? Only switch to 3V3 from the Teensy? I think, this will do…
Another idea was using generally a 3V3- supply. But what will the A4988 do while supplied with only 3V? Data sheet is saying: ‘ok’, but who knows? And LCD-display has to be completely changed or added an ICL7660 dc-dc converter to, to get a negative voltage for the displays contrast.
What did you do or what would you propose?
vy 73, Immo
Hi Immo,
I’m redrawing the schematics and using BAT54S (a SOT23 with 2 schottky’s) to protect each input line. I’m not sure the display needs extra work. In my case it’s working but I’m afraid to give you the same advice as I don’t want anybody to damage his own equipment. I’m open to suggestions to further protect the Teensy 4.0.
Another OM has succesfully connected the endoder via a bi-directional level shifter (https://www.antratek.be/logic-level-converter-bi-directional-bob-12009) but with the BAT54S it should also work.
73 de ON5IA
Frederik