Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


N9WXU last won the day on June 21 2020

N9WXU had the most liked content!

Community Reputation

55 Excellent

1 Follower

About N9WXU

  • Rank

Recent Profile Visitors

1,411 profile views
  1. Evan, This sort of news sounds very pertinent to the members of this forum. Please show us your technology!
  2. This is a user help forum for all topics on engineering and embedded software development. Feel free to browse the articles, ask questions and enjoy the fellowship of fellow embedded engineers. Welcome to the group.
  3. This is a quick note to warn everyone using the SAMD21 in an Arduino environment with the STL. I use C++ all the time and much of the power comes from using the STL. Vector, queue. array, etc are all canned, powerful libraries that make your life easier. However, the Arduino runtime environment for the SAMD21 conflicts with these libraries. Here is a quick example: #include <Arduino.h> #include <vector> using namespace std; vector<int> count; void setup() { Serial.begin(115200); count.push_back(0); } void loop() { Serial.println("Hello"); delay(500); } A trivial use of a vector to burn up all the RAM. Simply including the vector causes a conflict with the implementation of min(a,b) Building in release mode Compiling .pio/build/mkrzero/src/main.cpp.o In file included from /Users/joejulicher/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/7.2.1/vector:60:0, from src/main.cpp:3: /Users/joejulicher/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/7.2.1/bits/stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2 min(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /Users/joejulicher/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/7.2.1/bits/stl_algobase.h:265:56: error: macro "max" passed 3 arguments, but takes just 2 max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ In file included from src/main.cpp:2:0: /Users/joejulicher/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/7.2.1/bits/stl_algobase.h:195:5: error: expected unqualified-id before 'const' min(const _Tp& __a, const _Tp& __b) ^ /Users/joejulicher/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/7.2.1/bits/stl_algobase.h:195:5: error: expected ')' before 'const' /Users/joejulicher/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/7.2.1/bits/stl_algobase.h:195:5: error: expected ')' before 'const' The implementation of min for Arduino conflicts with the implementation for the STL. I have done this same build with ESP32 and STM32 and did not have these conflicts. Therefore these are SAMD21 "features". Fortunately you can easily work-around the issue by reversing the include order. Put vector (or other STL's) before the Arduino.h and it compiles just fine. Of course I have not exhaustively tested this combination so your milage may vary. Good Luck
  4. In case anyone was curious, and pictures or it did not happen. Here is the completed data collection unit. The engraving was with my laser. The PCB image is really a ChipKit (just a handy DXF I had). Unfortunately the laser water flow sensor had a leak so the tube overheated and lost power most of the they through the engraving. This has all been fixed and apparently no permanent damage. Oh well. It still looks nice. Front and back panels are laser cut acrylic. Blue extrusion is from here: https://www.amazon.com/dp/B07MPX23FS/ref=cm_sw_em_r_mt_dp_U_QPQ4Eb3MH0BNX The mounting flanges are these: https://www.amazon.com/dp/B07MZPFWKK/ref=cm_sw_em_r_mt_dp_U_BQQ4Eb6BE926B
  5. I have decided that I need dimmable lights in the cabin and the ability to load shed in a low power situation. The next feature will be a smart fuse block with individual BPS443 power switches for each circuit. Then I can turn off the refrigerator and dim the cabin lights at the fuse panel. Normally that would not be fantastic but in this case I simply want to bias the lights down a few percent so this will be fine. I won't use the SAMD21 for this project for other reasons which I will write about.
  6. Exactly! Lots of serial ports can be very useful in a variety of situations. Using these serial ports in the Arduino environment had a few challenges that the standard tutorials did not completely cover so I hope the Arduino SERCOM information I provided here is useful.
  7. The ANSEL and the TRIS registers work independently of each other. The RESET condition for both registers is ANALOG (all bits set) and INPUT (all bits set). This is not simply because all registers should be set to 1's (no true and not done) but rather, the lowest power/safest state of the device would be analog input followed by digital input because chip cannot know what is attached to each pin. Because ANSEL and TRIS are independent, you get some interesting side behavior. i.e. MCC always defaults to the reset state for each register. ANSEL does not impact the pin's ability to be an output (if you write to the LAT register) so leaving ANSEL set is safe but strange. In fact, it is possible to make an ADC conversion on an output pin and see how the pin is behaving (is it over loaded or charging a capacitor). I suppose the short answer is, setting the pin to output did not require disabling the analog feature so MCC did not do that.
  8. I am working on a project for my camping trailer. The trailer has a 200W solar panel charging a 100AH LiFe battery. This crazy amount of energy is used to run lights, a refrigerator and, more importantly, a laptop and telescope while I am in the field. There is the trailer stored in the yard. The grey metal on the front is a set of drawer slides holding the 200W 24v panel. The 24v works well for the MPPT's because I get charging voltage earlier in the morning. The 200W works well because I don't want to move the panels to track the sun while I am camping. Now I want a status panel for the entire trailer in my home office so I can see how prepared I am for camping at moments notice. When I bought the trailer I specified a custom electrical system. This system utilizes a lot of Victron Energy equipment because it works well and it has a serial port with a published specification. They even show off open source projects using their equipment. Here is the electrical box. It did get a bit tight. Each of the blue units is a device with serial data for monitoring. This box lives in the black equipment box on the trailer tongue. The serial port is called VE.Direct and it is a simple 1 second transmission of useful information at 19200 baud. Here is an example of a transmission recorded from the trailer. PID 0xA053 FW 146 SER# HQ1734RTXXT V 13500 I -180 VPV 39200 PPV 0 CS 5 MPPT 1 OR 0x00000000 ERR 0 LOAD ON IL 200 H19 2436 H20 21 H21 106 H22 27 H23 132 HSDS 117 Checksum $ I decided that step 1 in my project is to collect the data from the 3 devices in the box and report them to a second human interface/radio link in the back of the trailer. Here is my plan: This indicates that I need an MCU that has 5 serial ports and is easily programmed for my Hobby. I have been doing quite a bit of Arduino work in Platform IO and that combination is pretty good so how about using one of the many SAMD21 based Arduino kits. The SAMD21 has 6 SERCOM's that can be used for this purpose. So the first step... How easy is it to use 5 of the SERCOM's to do what I want? Not too bad but there are a few gotcha's. The SAMD21 Arduino support has a file called variant.cpp that defines a big array of structures to cover the capabilities of each pin. This structure includes a "default configuration" setting such as SERCOM, Analog, Digital, Timer, etc... When you open the serial port (Serial.begin(19200)) the serial library puts the pins into the "default" behavior and not the SERCOM behavior. Therefore if you want to use multiple sercom's you must do a few steps. 1) Ensure your SERCOM is initialized with the correct I/O pins. Uart ve1(&sercom2, sc2_rx, sc2_tx, SERCOM_RX_PAD_3, UART_TX_PAD_2); Uart ve2(&sercom3, sc3_rx, sc3_tx, SERCOM_RX_PAD_1, UART_TX_PAD_0); Uart ve3(&sercom1, sc1_rx, sc1_tx, SERCOM_RX_PAD_3, UART_TX_PAD_2); Uart ve4(&sercom4, sc4_rx, sc4_tx, SERCOM_RX_PAD_1, UART_TX_PAD_0); The tricky bit here is mapping the Arduino PIN number, to the SAMD21 Port/PIN numbers so you can determine which portmux settings are applicable. This is helpfully documented in the variant file but it is tedious especially since I build a custom PCB and had to keep track of every abstraction layer to ensure I hooked it up correctly. 2) Start the UARTS. ve1.begin(19200); ve2.begin(19200); ve3.begin(19200); ve4.begin(19200); This step was VERY simple and straight forward. 3) Put the new pins in the correct mode. pinPeripheral(sc1_tx, PIO_SERCOM); pinPeripheral(sc1_rx, PIO_SERCOM); pinPeripheral(sc2_tx, PIO_SERCOM); pinPeripheral(sc2_rx, PIO_SERCOM); pinPeripheral(sc3_tx, PIO_SERCOM); pinPeripheral(sc3_rx, PIO_SERCOM); pinPeripheral(sc4_tx, PIO_SERCOM_ALT); pinPeripheral(sc4_rx, PIO_SERCOM_ALT); The begin() function put each of these pins in their DEFAULT mode according to the variant table. But most of these pins did not have PIO_SERCOM as their default mode. You must call pinPeripheral() after you call begin() OR change the variant table. Naturally, my initial code did not but things did not work. Since I am working on this project off and on for some time, I found the bug in my VE.Direct class! The constructor was issuing the begin() which does make sense but it breaks the UART configuration that was already up and running. Now my serial ports are all running, and I am playing recorded messages to the system so I can debug inside where it is not 40C. On to the next problem. Good Luck
  9. I just received a care package from my father with a pile of old "junk". In there was a Speak and Spell from around 1978, I don't know when mine was bought. I quickly checked the battery compartment (4 C-cells) fearing to find a pile of corrosion. I did, but it was the rusty sort. The battery contacts were rusted. I opened the unit, removed the contacts and dropped them in vinegar to dissolve the rust. The contacts completely fell apart. A quick Amazon order for Keystone 209's and I was back in business. The new clips seem to be slightly thicker or perhaps stiffer, as the batteries are more difficult to insert. BUT it works! While I was waiting for the 209's to arrive, I considered adding an 18650 battery and a USB battery charger. The old TMS5100 series electronics runs from -15v so there is an inverting boost regulator to drop the 6v down to the -15. I tested and this works OK from 5v which is the standard output from the variety of battery manager/chargers you can find. But in the end I did not want a second button to activate the USB battery and then the normal ON button to activate the device. In any case, my 5 year old son loves it, though he did ask "can we install more games".
  10. N9WXU


    It is pretty hard to use on my 4K monitor as well.
  11. N9WXU


    Wow, this release seems pretty broken. I even tried to use FoundationServices i2c simple master. That installed, but did not get the underlying i2c master driver created so it cannot compile.
  12. N9WXU

    Home Offices!

    Time to share our home offices. Here is where I am spending my time lately.
  13. I am leaning towards adding a current transformer to the smart switch. Then I have positive feedback that the regulator is also commanding the motor to be on and I can more positively put a time limit on the motor run.
  14. A few weeks ago, I installed shop air in my garage. I was pretty proud when it held 150psi all night. But of course I did not quite tighten a connection and at 2 AM (or so my daughter tells me) there was a loud bang followed by a steady "compressor" noise. I did not notice until the next morning when I wondered why there was a noise from the garage. That compressor was pretty hot for running 6 hours straight. Of course this could be stopped by turning the compressor off each night. But, I write embedded software for a living and lately I have been deep into IoT projects. Naturally, this was an ideal chance to do something about my dumb compressor. Ingredients First, I needed a way to switch the compressor on-off remotely. These Sonoff switches are almost perfect. On the plus side, they have an ESP8266 inside so I can run TASOMOTA which is a generic Home Automation / IoT firmware for all things 8266. On the down side, they only are good for 10A. So I added a 120VAC 2 pole relay good for 30A. The compressor has a 16.6A motor draw so some overkill seems appropriate. I refreshed the Sonoff Basic with Tasmota and installed everything inside a metal electrical box. And when I visited the web page: I can turn the compressor on/off from my phone. Fantastic! As long as I had everything opened up, I went ahead and added 2 pressure sensors. Left and right of the primary pressure regulator. The left side sensor goes to the compressor and lets me know what it is doing. I am now tempted to remove the mechanical hysteretic controller on the compressor and simply use the Sonoff switch and some electronic pressure sensing to do the same thing. We shall see. Everything is now in place to ensure the compressor can be automatically turned off, or have a maximum run limit. The only thing left is software! Good Luck.
  15. I am glad to provide some ideas. Let us know what you find. Learning from others is generally cheaper and less painful than learning from my own mistakes.
  • Create New...