HAL – Software Wiring

Hardware Abstraction Layer is a thin layer of software that “abstract” your code away from the actual electronics. Actually one of the better implementations around is the Arduino library, so it is many good reasons to copy this as much as possible. But, not all of it as Arduino was implemented on a 8 bit AVR and uses a blocking concept.

One thing we need to do different is a concept I call “Software Wiring”. As we use a HAL UART module we also need to tell the HAL module where this UART is located and what pin’s to use. ST have GPIOA, GPIOB, GPIOC etc that are physical Groups of 16 pins each, but if you access these in your code you also need to change your code if Your platform change. This reduces the portability of your source code, so I deal with this using a simple trick in the HAL GPIO module.

For each UART I create a logical HAL GPIO group that need to be wired for the HAL UART module. HAL UART will expect that Rx/TX, Send Enable, Receive Enable and Power On/Off are on selected logical pins that never will change. This Group Access physical pins through a table allowing us to re-wire in software as we initialize our platform.

The result is that I am left with a single function that needs to be re-wired to port source code from platform to platform. Obviously we also enable the physical ports 1:1 through the same mechanism.

STM32F405RG Breakout

Finally updated Revision 1.2 of the Rx breakout board.

  • Minor correction ca 0.5 mm on width.
  • Correct GND/3.3V tag swap.
  • Added a User Led
  • Added a jumper for the user led. This is connected on the PCB, but you can disconnect the Led and add a jumper if you want the led on a different pin.
  • Added a Gnd connector for Oscilloscope.
  • Replaced the Ceramic Murata crystal with a hole through HC49 crystal. The Murata is nice, but the hole through is easier to remove for RC crystal apps or other frequencies.
  • Added X1 and X2 – VCAP capacitors to support STM32F4 – these must be replaced woth 0Ohm for F1.
  • Added a pull-up on NRST.

This board should be possible to use as breakout for a large range of STM32FxxxRx boards including STM32F103, STM32F105, STM32F107 and STM32F405. I need to check datasheets on other LQPF64 MCU’s from ST.

According to the datasheet this should also work for STM32F205Rx MCU’s. I have no plans to verify this at present. Myself I only use F105 and F405 With an option to use F107 since it provide Ethernet in LQFP64 package.

Sorting source code

I admit it sounds a bit ludicrous, but right now I miss an source code aware sort function in my IDE. If you start maintaining large files with loads of structures or functions you often end up paging up/down looking for them – to reduce this time I start sorting them in alphabetic order.

enum vm_OpCode
{
 Op_Assign=1,
 Op_Call=2,
 Op_Commit=3,
 Op_End=4,
 Op_Exit=5,
 Op_For=6,
 Op_If=7,
 Op_NOP =8,
 Op_On=9,
 Op_Raise=10,
 Op_Rollback=11,
 Op_Spawn=12,
 Op_State=13,
 Op_Switch=14,
 Op_Transaction=15,
 Op_Update=16,
 Op_While=17,
};

The struct above is another example – I sorted it to easier keep things synchronized – doing so is actually an increase in quality because it means the developer uses less time looking for things and get a better overview faster – each of these also have structs, execute functions etc.

CH340G Working

Nice to see CH340G finally registering correct on Windows. The circuit below works just fine.

The first you always should do is to measure if you have power – in this case 3.3V – I actually did, but as I finally measured on the pins I noticed that I actually did not. Looking at my schematics (and routing) I realized that I had connected the circuit to the wrong 3.3V that I had not assembled yet – doh…

It is an annoying error and even more annoying that I did not see it straight up. The real problem here is that I have made it difficult for myself not providing test points on a rather complex board . But, I am very happy to see this working as expected.

PLC Backbone Bus

Just updated the pin numbers on the PLC Backbone Bus. The idea here is that we have 4x RS-X lines (2 optional) and 5V,12V,24V,48V supplied from A and B source. The boards select what power they need. I need to connect to a PSU & battery before I am sure that this is what I want to do.

48V is mostly for higher motor effects. 24V & 12V are quite handy to have around, while 5V is an absolute requirement – thought I might actually ditch 5V and supply a separate 12V for MCU expecting the boards to regulate 5V/3.3V themselves. The idea of having a separate MCU power is to avoid the need for galvanic isolation as any effects are drawn from separate power lines.

PLC Backbone 3D

This is just an early 3D model of the minimum backbone bus just to illustrate and work on practical issues. I am going for the more minimal bus for now. The size of the bus do not decide the size of the boards, but I do like this small size. I will however adjust the actual size to practical applications.

What is missing here is a better way of interconnecting several boards and connecting to the PSU. But, I am happy with the PSU lanes – I had no problem using 2mm wide lanes on each side for GND,12V,24V,48V on both A and B. Simply said we can handle some currents in the backbone.

I added 8 slots expecting that we will use 4, but I also miss mechanical fittings of the IO boards here – as I plug IO boards in I need a mechanism to hold them in place.

It is several design considerations that is not solved yet – vibration, interconnection between boards, fixing of sub-boards, connection to RS-X networks etc. But, we need to start somewhere.

PLC Backbone 2

The previous proposal included a lot of data/address/function pins that actually is a bit obsolete design as we use multiple RS-X channels. This smaller bus uses 2×20. I can use the same width as for a Hat, but maybe a bit deeper boards.

I need the PLC system to be small and mobile to fit robots. I wanted a wider system to get more connector space, but I can add 2nd slots for those few cases. In short – I feel that increasing the size would be a mistake.

It is an alternative – and I could even do both …

PLC Backbone Bus

If I use a 10cm wide backbone I have room for a 2×30 (or 3×30) by 2.54 pitch “bus” that could contain the following Inventory:

Summarised this gives me:

  • 4 pin 5V PSU (5-10A)
  • 4 pin 12V PSU (5-10A)
  • 4 pin 24V PSU (5-10A)
  • 4 pin 48V PSU (5-10A)
  • 4 pin GND 5V
  • 4 pin GND 12,24,48
  • 8 pin data bus
  • 12 address bus
  • 10 function/extra address pins
  • 8 pin for 4 RS-X lines (RS485)
  • 2 clock pins

This is just a working draft…