Motoko reloaded - msp430 neural network line follower

line follower using two linear neurons (controllers) PD for differential and I for speed; both with antiwindup, error filtering and simulated annealing tunning (take about 80 loops in short testing line loop); second controll stage is curve predictor - table of curves to prevent overshoot (still present)

line follower

  • Actuators / output devices: DC Motors, pololu
  • Control method: modified pid with curve predictor, simulated annealing learning
  • CPU: msp430f2232
  • Operating system: none
  • Power source: 2S lipol 250mAh / 400mAh
  • Programming language: C, ruby
  • Sensors / input devices: accelerometer, gyro, 8x cny70, 3x ir
  • Target environment: indoor

This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/motoko-reloaded-msp430-neural-network-line-follower

** nice job**

very fast

**Very Nice **

How did you implement a nueral PID controller. It’s interesting

my PID controller equation

my PID controller equation (single neuron, with linear transfer with 4 inputs):

u(t) = u(t-1) + k1e(t) + k2e(t) + k3*e(t)

don’t forget limit u(t) value (real motor have maximal speed limited)

e(t) is error input from sensor; left sensor value is -4, right +4, in center is 0;

this should be filtered first, because difference calculation, and high quantization noise (from sensors you have only 8 values! (3 bits)), the best way is comb filter - i used 4th order, and if you are using fixed point don’t divide sum result with filter order

constants calculation from “textbook” equations :

k1 = kp + ki + kd

k2 = -kp - 2kd

k3 = kd

real magic is how to set kp, ki, kd; hebbian rule, backpropagation, Ziegler-Nichols or gradient self tuning may converge in local minima; simulated annealing can avoid this (but take long time), and it is simple to implement - only high quality random generator necessary (i used LFSR ^_^) ; all you need is fitness function; i used this : q = sum ( abs( err(t) ), where err is error obtained from line sensor, goal is to minimize q; one round takes 800 samples (about 4s with 200Hz sampling)

nice job²

you send me the code to study? I’m from Brazil and I became interested in control. misaelgpereira <at> gmail . com

sources release

currently i’m working on new firmware - evolution strategy PID tuning, motor controll transfer function has been also changed

sources will be released in approximately one month