SBC9302

February 1st, 2008

We received the SBC9302 a week back. The box had the board, a serial cable, a cd with development software and manuals, and a voltage eliminator for the board.

Linux was pre-installed and all we had to do was to use the serial RS232 cable to connect the board to the computer, then use Minicom (or HyperTerminal in Windows) to boot the embedded OS and get a terminal from it. We tried it and it worked perfectly. We got a terminal and most Linux commands worked. And the entire installation was not bigger than 8MB!

Next job was to try downloading programs onto the board and execute them. But to do that, we have to create a new OS image that has our program and then download it to the board. Atleast that was what the manual said. We tried compiling the code, but we had quite a few problems with that. None of us has done this before.

That was when this idea struck me. The manual says that the OS automatically mounts USB storage devices connected to the board. So we could use a thumb drive to connect and transfer our binary to the board. We wrote a small PID controller that has a simulated process on the desktop, so that it would compile on the normal desktop gcc compiler.

To compile it with the arm-linux-gcc I thought we had to make some modifications to the code. And I didn’t have a clue about the modifications that we had to make. They had not included a programming manual in the cd they gave us. So I tried compiling the same code with the arm-linux-gcc hoping that the compiler would suggest modifications. But unbelievably, the code compiled without errors! Here’s the code:

#include <stdio.h>
#include <pthread.h>

#define KP 15 / 10
#define KI 5 / 10
#define KD 10 / 10

float pid_control(float target, float current)
{
     float error;
     float delta_err;
     float p_out;
     float i_out;
     float d_out;
     float output;

     static signed int integral_err;
     static signed int prev_err;

     error = target-current;
     delta_err = prev_err-error;
     integral_err += error;

     if(integral_err >  200)
           integral_err  = 200;
     if(integral_err <  -200)
           integral_err  = -200;

     p_out = error * KP;
     i_out = integral_err * KI;
     d_out = delta_err * KD;
     output = p_out + i_out + d_out;

     if(output > 127)
           output = 127;
     if(output < -128)
           output = -128;

     prev_err = error;
     return (float)output + 128;
}

int main(void)
{
	float CO;
	float current,target;

	printf("Enter set point : ");
	scanf("%f",&target);

	printf("Enter initial controller output : ");
	scanf("%f",&current);

	while(1)
	{ 

		CO=pid_control(target,current);
		system("clear");
		printf("CO = %.2f",CO);
	        current=current+(CO-127)/10;
		printf("   Current = %.2f\n",current);
		sleep(1);
	}
}

And after transfering it to the board using a thumb drive, the program ran just as it had on the desktop. Wow! I had been wondering how I was going to learn the entire ARM architecture in a month, and on seeing this, I was flying with joy. This would save me a whole lot of work!

Still there is a long way to go. We have to design interface hardware, write device drivers for them, and get them all to work to gether. Lets see how it goes.



Leave a Comment