My next step learning robotics is to get the mimi-leonardo controller working with my Dagu Rover 5(Rover 5 Chassis).
As I cannot, as much as I search the internet, find any documentation re the mimi-leornardo I need help.
I have been given code by Dagu that is supposed to be what is on the controller and I would appreciate being able to use the Arduino IDE to upload same but cannot find a suitable board in tools in the IDE.
Suggestions please.
If you post a picture of the board we'd have a better chance of helping.
Some people have called the Pro Micro a "mini Leonardo" but I've never heard of a mimi-leonardo.
Steve
Just for clarification, I looked at the dagurobot link and saw that they offer a product called a mini-leonardo
The description indicates it has a ATmega32U4 along with dual 5A H-bridge, Bluetooth and direct plugin servo support.
Looks like this would be handy for rover projects.
Alas, I see no instructions on using the Arduino IDE. Perhaps you can reach out through the web site's 'contact us' information and ask.
Unfortunately thee mini-leonardo mentioned by vinceherman is not the board I got.
A photo of the board I was supplied can hopefully be seen at
The image is at www.stockton.co.za/mimi-leonardo.jpeg
That looks identical to the Dagu mini-leonardo apart from an extra heat sink.
It's a bit difficult to help since you haven't shown us the code you're trying to compile or what boards you've tried so far or what errors you get when you try.
Both Leonardo and Pro Mini look like they might be a good bet as they're both 32U4 boards.
Steve
If you go to the link in my post and look at the third picture, it shows both heat sinks. And the board looks the same to me.
Hmm.. Odd fitting to the wrong rectangle. I'll combine them on my PC and upload.
Thank you vinceherman that would appear to be a great step forward.
To answer slapstick, I have no software as yet and am open to recommendations. As I said in my original question I am quite new to robotics as well as arduino.
In your original question you said "I have been given code by Dagu that is supposed to be what is on the controller and I would appreciate being able to use the Arduino IDE to upload same but cannot find a suitable board in tools in the IDE."
Now you say you have no software. If you have no software what is it that you can't load using the IDE? I'm confused.
Steve
Sorry slapstick I had a brain failure. Alt Ctrl Del of my brain and I remember the code I spoke of.
The code we spoke of is:-
#include <Servo.h> //引入lib
#define PotA 6
#define BSGA 11
#define PotB 5
#define BSGB 10
Servo sv[12]; // 对!伺服可以是一个数组 Array of strings
int svc[8]={ // 伺服中心位置(通常为1500uS) Servo center position (usually 1500uS
90,90,90,90, // D27膝1,D28髋1,D29膝2,D46髋2
90,90 // D47膝3,D48髋3,D49膝4,D50髋4
};
int D0= 90,D1= 90,D2= 90,D3= 90,D4= 90,D5= 90,D6= 90,D7= 90;
const int MisoPin = A3;
const int MosiPin = A2;
const int SsPin = A1;
const int SckPin = A0;
int time1 = 250;
int pixelBrightness;
unsigned char PS2buf[10];
unsigned char i;
unsigned long t1, t2;
void setup()
{
sv[0].attach(0); // knee 1
delay(40);
sv[1].attach(1); // knee 1
delay(40);
sv[2].attach(2); // knee 2
delay(40);
sv[3].attach(3); // knee 2
delay(40);
sv[4].attach(4); // knee 3
delay(40);
sv[5].attach(7); // knee 4
delay(40);
pinMode(BSGA,OUTPUT);
pinMode(BSGB,OUTPUT);
pinMode(PotA,OUTPUT);
pinMode(PotB,OUTPUT);
//仅能使用PWM引脚
PS2_Init();
}
void loop()
{
t1 = millis();
if(millis() - t2 > 50)
{
t2 = millis();
if(Get_PS2Dat(PS2buf)==1)
{
switch (PS2buf[3] ) // 根据menu()的结果跳转
{
case 191 : orientation1(); break;
case 239 : orientation2(); break;
case 127 : orientation3(); break;
case 223 : orientation4(); break;
default: break;
}
switch (PS2buf[4] ) // 根据menu()的结果跳转
{
case 239 : orientation6(); break;
case 191 : orientation7(); break;
case 223 : orientation8(); break;
case 127 : orientation9(); break;
case 247 : orientation10(); break;
case 253 : orientation11(); break;
case 251 : orientation12(); break;
case 254 : orientation13(); break;
default: ; break;
}
/*
if(PS2buf[4]==247) //R1
{
time1 = time1 + 5;
if( time1 > 255)
time1 = 255;
}
if(PS2buf[4]==253) //R2
{
time1 = time1 - 5;
if( time1 < 5)
time1 = 0;
}
*/
}
}
}
void PS2_Init()
{
pinMode(SckPin,OUTPUT);
pinMode(MosiPin,OUTPUT);
pinMode(MisoPin,INPUT);
digitalWrite(MisoPin,HIGH);
digitalWrite(MosiPin,HIGH);
pinMode(SsPin,OUTPUT);
digitalWrite(SsPin,HIGH);
delay(30);
}
//-----GPIO
unsigned char PS2_RWByte(unsigned char id)
{
unsigned char i=0,j;
unsigned char od=0;
for(i=0;i<8;i++)
{
if( id&(1<<i) )
digitalWrite(MosiPin,HIGH);
else
digitalWrite(MosiPin,LOW);
digitalWrite(SckPin,LOW);
for(j=0;j<10;j++);
digitalWrite(SckPin,HIGH);
if(PINC&(1<<3))
od|=1<<i;
else
od|=0<<i;
}
return (od);
}
unsigned char Get_PS2Dat(unsigned char *buf)
{
unsigned char i;
digitalWrite(SsPin,LOW);
//delayMicroseconds(10);
buf[0]=PS2_RWByte(0x01);//delayMicroseconds(10); //延时再读取
buf[1]=PS2_RWByte(0x42);//delayMicroseconds(10);
buf[2]=PS2_RWByte(0x00);//delayMicroseconds(10);
buf[3]=PS2_RWByte(0x00);//delayMicroseconds(10);
buf[4]=PS2_RWByte(0x00);//delayMicroseconds(10);
buf[5]=PS2_RWByte(0x00);//delayMicroseconds(10);
buf[6]=PS2_RWByte(0x00);//delayMicroseconds(10);
buf[7]=PS2_RWByte(0x00);//delayMicroseconds(10);
buf[8]=PS2_RWByte(0x00);//delayMicroseconds(10);
digitalWrite(SsPin,HIGH);
if((buf[0]==0xff)&&(buf[1]==0x41)&&(buf[2]==0x5a)) //成功,普通模式
return 1;
if((buf[0]==0xff)&&(buf[1]==0x73)&&(buf[2]==0x5a)) //成功,摇杆扩展模式
return 2;
return 0;
}
void orientation1() //左前进
{
D0++;
if(D0>170)
D0=170;
sv[0].write(D0);
// digitalWrite(BSGA,LOW);
// digitalWrite(BSGB,LOW);
// analogWrite(PotB,time1); //PWM调速,输出PWM,占空比为PotBuffer/255
// analogWrite(PotA,time1); //PWM调速,输出PWM,占空比为PotBuffer/255
}
void orientation2() //左后退
{
D0--;
if(D0<50)
D0=50;
sv[0].write(D0);
}
void orientation3() //左左
{
D1++;
if(D1>180)
D1=180;
sv[1].write(D1);
}
void orientation4() //左右
{
D1--;
if(D1<1)
D1=1;
sv[1].write(D1);
}
void orientation5()
{
}
void orientation6() //右摇杆前
{
D2++;
if(D2>180)
D2=180;
sv[2].write(D2);
}
void orientation7() //右摇杆后
{
D2--;
if(D2<20)
D2=20;
sv[2].write(D2);
}
void orientation8() //右摇杆右
{
D3++;
if(D3>180)
D3=180;
sv[3].write(D3);
}
void orientation9() //右摇杆左
{
D3--;
if(D3<1)
D3=1;
sv[3].write(D3);
}
void orientation10() //R1
{
D4++;
if(D4>100)
D4=100;
sv[4].write(D4);
}
void orientation11() //R2
{
D4--;
if(D4<40)
D4=40;
sv[4].write(D4);
}
void orientation12() //L1
{
D5++;
if(D5>105)
D5=105;
sv[5].write(D5);
}
void orientation13() //L2
{
D5--;
if(D5<1)
D5=1;
sv[5].write(D5);
}
unfortunately I do not read chinese(if those comments are chinese) so even though I have managed to compile and upload this code and for a short while got a very bright 13, where do I go from here?
So you do have the code, you have found a board that suits it, it does compile and load.
We can't see what you have or are doing. E.g. is the board connected up to the rover? It looks like it expects a PS2 controller to run it. Do you have one connected? Does it do anything. Do you know what it's supposed to do and what you're supposed to do to make it do something?
Steve
So you do have the code, you have found a board that suits it, it does compile and load.
We can't see what you have or are doing. E.g. is the board connected up to the rover? It looks like it expects a PS2 controller to run it. Do you have one connected? Does it do anything. Do you know what it's supposed to do and what you're supposed to do to make it do something?
Steve
Firstly, slipstick I apologise for misspelling your user name earlier.
Thank you one and all for the help given so far.
First decision that I need to make is do I spend time trying to debug the code sent to me from China or do I write my own.
I am a retired programmer and I know that debugging someone elses code is a major pain. Might be a lot easier with help from this forum to write my own. On the other hand I may learn something looking at their code.
My goals for the Rover 5 is basically to learn robotics but 1st I'll have to get it to move, then get it to move in a controlled manner and then get it to move on my command, either WiFi or RC or Bluetooth, have not thought that far yet.
I notice you didn't answer any of my questions so I'll just wish you luck with your plans to experiment with your Rover 5.
As one retired programmer to another I'd suggest that analysing the code you already have to understand what it is trying to do and what is connected where is your best starting point. Unless of course you have some good quality and detailed documentation of both the board and rover which is surely what you'll need to write your own code.
Good Luck - Steve
Steve, with the Chinese software on the board and the board connected to the motors as well as to two 18650 and the board switched on, nothing happens.
I have checked the polarity of the batteries connection as well as the motor connections.
I do not know what the software is supposed to do but assume(ass U me) it is supposed to control the motors as well as give control and feedback to/from the motor encoders.
Please tell me if there are any further questions that I may be able to answer.
Just from looking at the code it seems to be for a device with at least 5 servos (called knees in the comments) and controlled by a PS2 Controller. There isn't much that looks like it may be related to motors but what little there is is commented out.
That doesn't sound anything like what the internet tells me is a Rover 5, a tracked device with a couple of motors and maybe encoders and not much else. Are you sure that code is intended for a mini-leonardo to run your rover?
That's about the best I can do so I think you're on your own with this. Trying to troubleshoot components that may not be compatible with software that may be intended to run something completely different and no documentation for any of it is way outside my abilities.
BTW if you do want to read the code comments just type "Google translate chinese to english" in a browser then you can paste a comment into the box and get the translation. The couple I looked at weren't very helpful though which just goes to show that Chinese coders are much like coders the world over.
Good luck - Steve
Thank you Steve, it is exactly as I suspected. More code there than is warrented in controlling two motors. What I find interesting is the reference in the code to the correct pins for the motors or have I misread.
#define PotA 6
#define BSGA 11
#define PotB 5
#define BSGB 10
and further on
pinMode(BSGA,OUTPUT);
pinMode(BSGB,OUTPUT);
pinMode(PotA,OUTPUT);
pinMode(PotB,OUTPUT);
and as you pointed out the following commented out
// digitalWrite(BSGA,LOW);
// digitalWrite(BSGB,LOW);
// analogWrite(PotB,time1); //PWM调速,输出PWM,占空比为PotBuffer/255
// analogWrite(PotA,time1); //PWM调速,输出PWM,占空比为PotBuffer/255
This code was supplied to me by the Rover 5 manufacturer as the driver for the Rover 5.
I am going to write my own and when that works I'll let you know.
Thank you for all the help.
Regards, Alf.
I cannot believe that something this simple took me so long. I must be getting senile but it now works.
I completely ignored the chinese program and with a bit of help from various on the internet wrote my own.