Data Logger

I recently made a Data Logger using a Nucleo-144 board and 16 bit ADC’s – the project works well and I am a bit surpriced over how easy it was to create both electronics, firmware and PC software, so I will attempt an even more advanced Data Logger illustrated below:

A functional block diagram over HW is illustrated above.

The ADC part is the more complex part. My original project used fast, internal 16 bit ADC’s, while this will use fast, external 24 bit ADC’s with full galvanic isolation. The sampling rate drops from close to 1Mhz to 68KHz, but this is sufficient. If you want higher sampling rates you would be using FPGA/ASIC anyway. The more complex part is the analogue setup at right- 0-10V analogue channels are straight forward, but I need to figure out how to support 4-20mA loops as well and try to avoid noise. Using a 24 bit ADC is a bit ambigous since it tend to be 8 bit extra noise compared to a 16 bit.

The MCU ss a STM32H723 rinning at 550Mhz with Ethernet. The key to this logging is to get data over to a PC (or Raspberry PI), but I have added a SD Card as well as a Quad PSRAM as well, PSRAM is 16Mb data buffer.

USB port is mainly for initial config and development.

I have done an early physical mock-up of the board and this will end up being the first ever project where I do SW/FW before doing HW.

The rational behind this project was that we needed a logger and struggled to find one that did what we wanted, so we decided just use a Nucleo-144 board and get going – the project was done with HW, FW and SW in 3 weeks. It does exist commercial solutions, but the ones I found cost a fortune and they are surprinsingly limited compared to how easy it was to make this one.

PLC – H503CB Base Module

This mornings catch… Made a new STM32H503CB base module. Swapped in STM32H503CB, a new 10 point 1.25 connector, my old SWD connector and a smaller SPI Flash. I also reversed 0402 trancient capacitors back to 0603 packages for now – I will reconsider moving to 0402 as I get the P&P working.

The Molex 10p connector at left have TTL IO only – CAN, USB, UART + 2 GPIO pins and 5V + GND. This will work well both as a module and as stand-alone with a small adapter board. I am out of space, but will add som TVS transient protection diodes on the back – more correctly 8 small diodes – either that or I need to use ca 5mm extra. I might consider full galvanic isolation as well if I find a solution for the 5V. Decent galvanic isolation on TTL is very straight forward, but I feel this is an overkill since we still have a galvanic isolation layer at right here towards the IO.

This SWD needs solering for dev purposes, but you can use a truck with a stick-in plug for just programming, so you do in effect have just a footprint SWD if you want to. I had no problem with this SWD over the years, but I will make some new adapter boards for it.

Mobile PLC – New Module Design

This is a PowerPoint mock-up. I just soldered om the PLCDCMotor board and im considering to keep the board as is with a less changes than I planned – the TTL connector at left can be used as is with a short 1:1 cable to a small board that convert the board to a stand-alone board. The M12 on right can be replaced with a custom connector to fit the IO on the board. I am not leaving the M12 design, but I think it is wise to include more options.

The nice thing about this is that I can just extend the TTL connector at left as the com adapter boards can be added later. I will add CAN and USB pins extending to a 8 pin TTL connector. I like these connectors because I can buy 1:1 cables in bundles ready made – if not they would be a lot of work.

This board was tight to hand-solder, but the real pain is the SWD at the left, bottom corner. That connector works fine, but it is very hard to keep it connected and is a major mistake. in fact I can achieve the same without soldering using my original SWD with 6 pins. Lesson learned!

STM32H503CB

STM32H503CB is fastly turning into my favorite MCU for three reasons – it is fast, it is low cost and it has en extremely good IO routing system.

It’s only drawback is 128Kb Flash and 32Kb SRAM, but it exist other MCU’s in the same series with more (that also cost more). That said it also contains a good bootloader in ROM, meaning the 128Kb Flash is all user application.

  • 32 bit M33 core running at 250Mhz
  • Cost lower than 2.- USD in decent volumes.
  • 128Kb Flash, 32Kb SRAM
  • And an IO system that contains a lot and is very flexible in routing to pins.

The example setup above contains:

  • USB
  • 1 x UART
  • 1 x FD-CAN
  • 3 x GPIO
  • Oscillolater
  • SWD
  • 4 x ADC channels
  • 4 x PWM channels
  • 3 x Ebcoder channels
  • 3 x SPI
  • 1 x I2C

All pins used on a LQFP48. Selecting IO with a H5 is in general very easy compared to other MCU’s, meaning you get a lot out of this one.

PLC – Modified 10A Motor Driver

Using my M12 DCMotor driver as base I want to upgrade this board as described below – running motors are fun and this board is capable 10A (actually 2 x 10A) at 24V, so it is quite powerfully.

This board is very capable as each driver privide two separate half H-Bridge circuits with current sensors at 5A each. I think I can drive a 10A 3-phase from this, but I can drive 4 solenoids, 2 DC motors or a larger Stepper motor. For now I will just build and code this in the M12 format, but I am starting to plan a simpler version to drive cost down.

  • The first change is that the connector on left is a fast TTL UART. I would like to replace that with something that enables the module to be used stand-alone and still be used as a module in a system. The answer is CAN, RS485 or RS232, but I need to research a bit on cost, speed and space usage. I also want to evaluate changing that micro connetor to terminals. One of the signals is an enable signal that switch on/off the PSU, so I need a jumper for that to be used in stand-alone mode.
  • MCU used here is STM32G491Cx and I will replace it with STM32H503Cx due to cost. H503 is M33 at 250Mhz and contains 128Kb Flash and 32Kb SRAM, but it has a very nice bootloader in ROM so the 128Kb Flash is for application only – and 128Kb is quite a lot as long as you don’t drag in Ethernet or similar.
  • The SPI Flash is great in SO8 format, but I have changed to a even smaller footprint to save space – and space is an issue on this design. One argument is also that I might be better off with a FRAM/EEPROM in this case since this is a motor controller.
  • The SWD connector at bottom left will be replaced with my old SWD connector.
  • Current sensor in middle bottom will be removed and replaced with 4 x current sensors on the DRV8873. This put the galvanic isolation layer in question as it is very difficult to have an analogue signal to cross galvanic isolation . it is possible, but I need to evaluate what I do here. DRV8873 is not isolated themselves, so it might be an overkill to have this isolation barrier + I could maybe add an isolation barrier on the connector at left.
  • The big 24 to 5V DC/DC is not needed – firstly I can replace it with a smaller SMD DC/DC from RECON, but secondly it serves no purpose if I remove the isolation layer.
  • 24V connector needs to be evaluated – swap it for a terminal and maybe feed 5V from this to reduce power to 1 connector.
  • The final change is to replace M12 with a terminal block due to cost.
  • One major issue as I designed this was size – this board is 25 x 70mm, but without the M12 design I can use whatever size I want.

 

Desktop PLC

This is a 4 x PWM or 2 x DC or 1 x Stepper motor driver. I have these boards already so I will solder one up for test later, but I will also design a new board with a few differences.

  • MCU used here is a STM32G491Cx – these are good, but expensive so I want to replace them with a STM32H503Cx that cost less. This is actually a somewhat faster M33 MCU ticking at 250Mhz.
  • I will go back to my old SWD connector for now.
  • SPI Flash will be replaced with a smaller footprint one (or maybe not for this as I have a lot of these that I need to use).
  • I will replace the M12 connector with a terminal block.
  • I will replace the connector at left with … not sure. I also want to look into making this stand alone.
  • The big square on top middle is a DC/DC – I would like to replace that, but to do so I need to widen the board a bit so I keep galvanic isolation intact.
  • I need to check isolation levels on the drivers.

I must admit M12 connectors look good once mounted – these boards and connectors are nice, but to expensive for normal usage. Terminal blocks are more practical for desktop testing.

ECU

This ECU box is sold on Aliexpress for ca 30.- USD and include the connector. On my M12 design I was stuck with expensive M12 connectors, so this offers a cheaper way to get a waterproof, shielded box.

 

The motherboard and daughteboards below are designed so it contains PSU, Ethernet, 2 x CAN, main MCU amd 1, 2 or 4 daughter cards to form a complete ECU.

This is just a classic mock-up to see if I have physical space for what I want to do. But, I have some conserns:

  • Ethernet is good, but 100Mbps Ethernet might nor work over that connector so it might be degraded to 10Mbps.
  • PSU – firstly a fully isolated PSU is included on 24V itself, but I struggle to support 10A.
  • I was thinking a simple, linear regulator for 5V, but I just did that and realized what a misstake it was. The board used 250mA and 250mA on 24V is 6W – the regulator overheat without cooling. So in short I need a 2A 24 to 5V regulator as well.
  • The daughter boards restrict PSU size.
  • The commector has no key options.
  • Ethernet + CAN is a bit of a waste – you don’t need both.

It is an interesting experiment, but I am not there yet. To move on I am considering doing a version of the M12 design with normal connectors and ditch ECU requirements just so I can focus on SW development and dev-kits for BSA. I need to split out the PSU design and get it to work + I would like to do a Ethernet design on H573 because this comes with Ethernet in 64 pin package-I am still a big fan of H723 and G4 MCU’s, but H503 costing 2.- USD is a very promissing option to lower cost even in smaller volumes.

As for IO

  • Ethernet
  • CAN
  • PWM out – the boards above is actually 4 x PWM @5A each.
  • Analogue In.
  • Digital In/Out
  • Power Servo channels

This is what I have with full galvanic isolation – the challenge has been more the connector and boxing side of the project + the obvious time in between projects that pay my bills 🙂

As for actual ECU design – a professional ECU will need ASIL-D/SIL3 qualification and I am preparing for that, but that is a big job. So for now I ignore this and just experiment on my way.

 

 

Mobile PLC

I received this board earlier and it was straight up with a few notes (See below picture).

#1 MCU worked fine. I had issues with too old soldier paste, but got some new paste and it was ok. I did try stensils this time – it kind-of worked, but my main problem is that I starved som solder pads so I need to get a proper stensil machine before I use a P&P.

#2 The new SWD connector is a misstake. I made it work by using a plier to hold the pins in position, but I need the clip version or go back to the old design. This is a bit troublesome because the version with clip holes occupy a lot of space. More research will ne needed here.

#3 The foorprint on the CAN Tranceiver was wrong – the actual tranceiver is wider – I managed to solder one channel by bending the legs under the wider body + I have another board with correct footprint for testing.

#4 Both Schematics and footprint on USB was utter bogus. I picked up a package and did not check it properly – it was bad – very bad. USB is very easy, so this took me with surprice.

¤5 I am surpriced about the high power usage – switching on everything I ended up in 200 – 250mA on 5V on the H723.

All in All I am happy with this board as such because it works well. I am not so happy with the M12 connectors. They work fine for CAN and Ethernet etc, but they are expensive and very limiting for everything else so I started on an alternative experiment drafted below. This is an ECU designed for a special pre-made box with a waterproof 56 pin connector. The concept is the same as above, but it has PSU on the motherboard and 4 add-on boards controlling 9 IO pins each. I have changed the main MCU to be H573, added Ethernet and reduced to 2 x CAN, but the main difference is the usage of a standard box and connector that is more friendly towards various IO pins.

Switching from H723 to H573 is partly due to cost + power usage. H723 is very powerfully and with all the IO boards you basically end up with a lot of CPU power and current usage you don’t need. Also the smaller modules changes to use H503 since the cost of this is ca 2.- USD even in Norway. H5 is still a M33 ticking at 250Mhz.

The main challenge is the isolated PSU – isolated 24V @ 10A that is. I am trying to do a flyback converter using 5 small 1:1 transformers rather than one due to size and must admit that I am a bit on thin ice. As a start I might just sod the isolation on 24V just to get going. I probably should do push-pull, but to be honest I will ditch the 24V isolation on the first prototype and make a special experiment on isolated PSU modules to get experience.

I did howver complete a different design for a customer that is a Data Logger – I used H723 to log 9 x 16 bit channels in high frequency and send the data on Ethernet. SW was done very fast thanks to STM32CubeIDE and AI even if I had to correct a lot of bugs. The entire embedded SW package was done in 1,5 weeks and the electronics in a few days – I just need to get a box and some connectors and it is job done.

The last job was done because we needed something fast and H723 was a candidate since it had 16 bit ADC’s, Ethernet and I already knew the MCU. The rationale behind doing something was that we struggled to find anything that could sample, filter and log in decent frequencies. To avoid risk I used a Nucleo board and just added a carrier board – this adds size, but we did not care in this case – I did not want to drag to much electronics risk into a project.

Just the electronics for competive solutions is in the region of 1200.- USD and we did not find any solution that could sample at high speed and transfer the data to a PC real-time. And it is not lost to me that I now sample at very high speed on multiple channels and can watch it real-time on a PC – this is basically a 9 channel Oscilloscop handling up to 1Mhz per channel. ST ADC’s are very nice as you just set them up combined with DMA that does all the hard work. The bauty of this logger is that you just add more boxes to get more channels on a solution and it is a very straight forward project to do.

My release of BSA have suffered a bit in the middle of this – it is not forgotten – it is just that real-live kicks in and I have to pay the bills as well + the ambiguity in my projects are high 🙂

BSA – Class vs Diagram

The following diagram is an example of a Class and an associated Diagram – see text below picture:

In BSA a Class and a Diagram can be the same as they can precent different aspects of the same object. A Class itself is only an overview of an object, but a Class Diagram adds inheritance and associations showing relations to other classes. The PLD Diagram visualize logics connected with methods and events that is not shown in a Class Diagram. The above, simple example illustrate some of this.

Here we create an object that can send an email to a customer. You see the simple PLD logic at right and a definition of the class “Customer” hidden inside the diagram “Customer”. This is fully legal. Notice that the content of Class “Customer” is the same as variables, methods and events in the diagram.

I will return a bit to the nitty gritty details on how this links together – I have a draft that I will implement today and then I need to test it a bit. But, the real test comes as I start activating the code generators – which is the next phase coming very soon.

BSA – Diagram Linking

I needed to consolidate PLD a bit around calls to sub-diagrams and functions, so I added a new diagram symbol and a new function call symbol. These overlap a bit, but the diagram symbol show a different diagram being used as a sub-diagram. If you double-click on that you will navigate tothat diagram. The signals in/out are connected to methods and events on the diagram. Name will be maintained automatically to be syncronized and you have a new context menu that allow you to link to a different diagram or create a new.  The diagram can be drawn rather freely as the editor will not check rules and integrity – that is what the compiler will do. This is rather important as it offers a designer the option to do fast hight level drafting and worry about executable details as the design matures. The incomung signals can display methods and events used if required. The function call uses a specific method in a diagram. You can do the same by using a diagram, so it’s a bit up to you.

I need to add in Classes in the diagram linking, but after that it is only testing/bug-fixing before the Beta will be released.