Skip to content

It’s Alive! Olduino/370 Carbot Spins its Wheels!

October 17, 2018

I was amazed that the MVS part of this worked so easily. I had made some simple C wrappers for the wiringMVS pinMode, digitalWrite, and delay functions. Once I got the Pi hooked correctly to the motor driver board I was easily able to run a batch job to access the robot car wheel motors.

I need now a good solid mount for the Pi as well as getting the input functions working. I’m using the adapter board from the 1802 carbot because it’s handy but it’s striking how the Pi needs many of the same crutches as the 1802 did including software PWM, an outboard analog-digital conversion, and extra resistors to access the ultrasonic range finder.
In the still image, the pi is in the lower left with eight leads going up to the adapter board. The motor power pack is below and behind it. The car body on the right came from an RC car with two independent rear motors, the four leads going left to the motor driver board are motor power, the two on the right are connected to the logic power pack which isn’t hooked to anything.

For each motor, the driver board takes three inputs, for the right side it’s PWMA, AIN1, and AIN2. AIN1 and AIN2 determine the direction the motor rotates and PWMA determines how hard it spins. In this case I’m just setting the PWM to full on but I can cycle it off and on to control speed.

The adapter board also has spots to attach an ultrasonic sideways sensor and an IR forward distance sensor with an ADC converter. It has a spot for a boost converter to generate 5V for the logic from two AA batteries. Probably the simplest approach is to make something similar but smaller and more suited to the Pi’s form factor. If it can fit into the 370 case, great.

#define INPUT 0
#define OUTPUT 1
#define LOW 0
#define HIGH 1
int setup(){
	int retval='s';
	asm(" LA 0,X'42' FLAG FOR SVC 255 ");
	asm(" LA 1,6 SETUP ");
	asm(" SVC 255 ISSUE SVC\n" 
	    " LR %0,15"
	    : "=r" (retval));
	printf("setup return value is %d\n",retval);
	return retval;
int digitalWrite(int pin, int value){
	asm(" LR 2,%0 \n"
	    " LR 1,%1\n"
	    " LA 0,X'42' FLAG FOR SVC 255 \n"
	    " SVC 255 ISSUE SVC" 
	    : /*no outputs*/
	    : "r" (pin), "r" ((value!=0)+2));
int pinMode(int pin, int value){
	asm(" LR 2,%0 \n" //pin
	    " LR 1,%1\n"  //value
	    " LA 0,X'42' FLAG FOR SVC 255 \n"
	    " SVC 255 ISSUE SVC" 
	    : /*no outputs*/
	    : "r" (pin), "r" ((value!=0)));
void delay(int value){
	asm(" LR 2,%0 \n" //ddelay time in MS
	    " LA 1,5\n"   //code for delay
	    " LA 0,X'42' FLAG FOR SVC 255 \n"
	    " SVC 255 ISSUE SVC" 
	    : /*no outputs*/
	    : "r" (value));
int main(int argc, char *argv[])
	int retval=43;
	//int pwmb=0,bin1=2,bin2=3; //speed and direction control for left side motor
	//int pwma=1,ain1=4,ain2=3; //speed and direction control for right side motor
	asm(" WTO 'Hello Moto!' ");
	pinMode(0,OUTPUT);pinMode(2,OUTPUT);pinMode(3,OUTPUT); //Left side motor
	pinMode(1,OUTPUT);pinMode(4,OUTPUT);pinMode(5,OUTPUT); //Right side motor

	//drive left side forward for 1.5 sec

	asm(" WTO 'OK Bye' ");
   	return retval;

From → carbot, Olduino/370

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: