Monday, June 15, 2009

After some frustration, I have the smallest amount of progress, and thought I'd post it. Others may have similiar issues.

I've been having issues with the bootloader which can be configured to automatically reset the STM32 chip in flash mode, without the need to change the chip from bootload mode to flash mode and then push the reset button. In my case, a lot of the times after my code changes, the chip doesn't boot from the bootloader, and I have to change to flash mode and reset.

I'm pretty sure that the problem is with the C "linker" that was default for my project, so I've been looking off an on over the last several days for the linker script file, which is supposed to tell the C compiler where the different variables, constants, RAM based and Flash based code should be put within the STM32's 4 GB potential address space.

In my project, there is a default link file enabled, and I searched on it a couple of times, trying to find it so I could check the file contents and settings. Alas, it was reported not found by windows file search program.

Today, I did a more exhaustive manual directory search, and found some of the Raisonance sample projects have a normal link file, and some have a .elf.ld link file. This will be due to the different memory usages ofthe different Raisonance code samples.

I kept looking, and found a generic script file that was almost the same as that in the project defaults, only with the second and third letters of the file name transposed.

Just one small, but infuriating little error. I don't know that I would have the patience to develop on a platform like this if I was younger, and had not had the winning experiences I've had with assembler in 8-bit microcontroller platforms, but I don't loose sight of the promise at the end of this project. The C language itself is not bad, it makes a lot of use of symbols in a tightly packed manner, and so you can end up having an extremely dense piece of code fitting into one line, but then you can end up surrounding it with a { on the preceeding line, and a } on the line following to tidy the look of your code. Weird.

So, I now know where the linker configuration file is, and what it's real name is, I can move it to my project directory and fiddle with it. There's a lot of waffle in it...*

Tuesday, June 9, 2009

How Graham decided to make better Jet units for his RC boats:

This blog is, at the moment ! dedicated to my motherboard design for a 3D materials processing machine.

I started this as a 2009 new year's project, and by the end of January 2009, I made the decision (having built the 3D stage), that I didn't want to buy a soon to be obsoleted circuit board to control it. Having been previously in business for myself as an electronics and software engineer, to proceed, my next step was to design my own circuit board.

This is what I came up with:
You can see at top right, the axis power electronics for 4 x stepper motor control, with 2 coils each, and 2 connections to each coil !
Down the left side, from top to bottom, are:
  • PWM transistor outputs 1 to 5
  • RS485 expansion
  • I2C expansion
  • Keypad

The grey looking square in the middle bottom position is the brain, an ARM Cortex M3 16/32 bit processor. It's great great great great great great great "it" was the acorn archimedes ARM, a much aclaimed microcontroller that was superior to the Intel x86 chips of the day, but not marketed as sucessfully. In interesting trivia, one of the main designers of the chip was "gender reassigned" and became female. Since then, ARM has undergone changes, and is now marketed as IP to big Silicon chip manufacturing companies.
STMicroelectronics, a company that seems to specialise in maximising I/O flexibility of it's product offerings, joined in, in utilising the Arm Cortex M3 core for products of it's own fairly early on, and I'm using their STM32F103VBT for my circuitboard.

In addition to the features I listed above, I also implemented these:
2 x position encoder channels (each channel uses two sensors)
2 x dedicated analogue voltage inputs, intended for temperature monitoring.
1 x Piezo with direct drive. You can actually play tunes on the stepper motors, but it's slightly more tricky to do if you don't want the stepper motors to actually move out of position !
5 x Servo control outputs, also configurable for other purposes if enabled as such in the software.
1 x LCD connector, for common 4 wire data mode.
1 x SD Card socket, for stand alone 3D model building operation.
1 x RS232 connection for loading the firmware, and available for debugging, diagnostics, or reporting purposes.
1 x RS485 connection for slave devices, or daisy chaining more of the same.
Anyway, those were the goals !

I designed to use the L298 chip, which is good for 2 amps continous. I decided to do that, because it handles the majority of small stepper motor control applications, and in that way, increases the potential volume traded of standard type circuitboards. That helps on both standardisation, and cost.

Most people use a decoder chip, like the L297 to interface between the brain on the circuitboard (the microcontroller or uC for short), and the power output hardware (the L298), but in my case, I decided to control the L298 directly, which allows for some tricks, I can potentially send wave forms via PWM to the stepper motors for smoother movement, and with sub steps inside what would otherwise be available.

The picture above was just the "artist's impression", generated by KiCad as a 3D view of the known components 3D shapes.

Anyway, I completed the design, and sent the plans to PCBCART in Hong Kong.
A couple of weeks later (I used the no-hurry-schedule ordering option), I got fifteen circuitboards from them:

It took me a couple of weeks to get all the components together to make the first one, and this is what it looked like:

You can see it at the right, perched on the EEEBOX that I bought for it, as a Windos server.

I use Linux otherwise, but it's quite messy getting started with ARM C programming, and so I used a better known environment. The EEEPC is low powered as Intel computers go, it uses an Atom processor, and isn't much good for keeping hands warm on cold winter nights.

Next was software !
I got the stepper motors running after taking some time to learn C (I used to use assembler only, on the embedded microcontroller end), and some battles to get the tool chain doing what I wanted it to. Pulse width modulating the steppers was second, and then applying the PWM to the coils independently in a wave form. I have that now, but at the moment only as a crude 1/2 steps between the 4 full power positions.

Next, (and up to date progress), was the LCD !
I got that working tonight, the picture's a bit dark, but you can see it on the bottom right hand side:

End of the day's post !