Go Down

Topic: SLA7043m serial in to micro stepping out (Read 2792 times) previous topic - next topic

miette

hello , this is my first try at serial communication with electronic
i have read this article http://www.arduino.cc/en/Tutorial/SoftwareSerial
and so the bit mask http://arduino.cc/en/Tutorial/BitMask to understand better about serial communication

the component i try to use is a SLA7043M , i couldnd find the datasheet so i am referring to the datasheet of SLA7042M - SLA7044M
http://www.datasheetcatalog.org/datasheets/50/338893_DS.pdf

i think i have (+/-) understood the theory for doing it
my motor is not working as it should , it is not because of the wiring , i am sure about that (i am injecting the data directly on a old printer pcb so the motors are already wired)

i would like to know if somebody could take a look at my code to check if i am doing it right

and if it is , could somebody help me to calculate the "timing" for this component (because all the times high and low seems different so i get confused)

thank you a lot

Code: [Select]


#include <ctype.h>

#define bit9600Delay 84 
//#define halfBit9600Delay 42
//#define bit4800Delay 188
//#define halfBit4800Delay 94

int DATAA = 0;
int DATAB = 1;
int CLOCKA = 2;
int CLOCKB = 3;
int STROBA = 4;
int STROBB = 5;

//byte SWval;

//byte n0,n1,n2,n3,n4,n5,n6,n7,i0,i1,i2,i3,i4,i5,i6,i7;
// nx is a normal out  , ix is a invert out                     as on page 46    http://www.datasheetcatalog.org/datasheets/50/338893_DS.pdf
byte n0 = 11000000;
byte n1 = 11110000;
byte n2 = 11001100;
byte n3 = 11111100;
byte n4 = 11000011;
byte n5 = 11110011;
byte n6 = 11000011;
byte n7 = 11111111;
byte i0 = 00000000;
byte i1 = 00110000;
byte i2 = 00001100;
byte i3 = 00111100;
byte i4 = 00000011;
byte i5 = 00110011;
byte i6 = 00001111;
byte i7 = 00111111;

void setup() {
  pinMode(DATAA,OUTPUT);
  pinMode(DATAB,OUTPUT);
  pinMode(CLOCKA,OUTPUT);
  pinMode(CLOCKB,OUTPUT);
  pinMode(STROBA,OUTPUT);
  pinMode(STROBB,OUTPUT);

  //digitalWrite(tx,HIGH);
  //digitalWrite(13,HIGH); //turn on debugging LED
  //SWprint('h');  //debugging hello
  //SWprint('i');
  //SWprint(10); //carriage return
}

void dataAPrint(int data)
{
  byte mask;
  //byte maskb;
  //startbit
  //digitalWrite(tx,LOW);
 
  delayMicroseconds(bit9600Delay);
 
  for (mask = 0x01; mask>0; mask <<= 1) {
    digitalWrite(CLOCKA,HIGH);
    if (data & mask){ // choose bit
     digitalWrite(DATAA,HIGH); // send 1
    }
    else{
     digitalWrite(DATAA,LOW); // send 0
    }
    delayMicroseconds(bit9600Delay);
   
    digitalWrite(CLOCKA,LOW);
   
    if (data & mask){ // choose bit
     digitalWrite(DATAA,HIGH); // send 1
    }
    else{
     digitalWrite(DATAA,LOW); // send 0
    }
    delayMicroseconds(bit9600Delay);
  }
 
 
  //stop bit
  //digitalWrite(tx, HIGH);
  digitalWrite(STROBA,HIGH);
  delayMicroseconds(bit9600Delay);
  digitalWrite(STROBA,LOW);
}

void dataBPrint(int data)
{
  byte mask;
  //byte maskb;
  //startbit
  //digitalWrite(tx,LOW);
 
  delayMicroseconds(bit9600Delay);
 
  for (mask = 0x01; mask>0; mask <<= 1) {
    digitalWrite(CLOCKB,HIGH);
    if (data & mask){ // choose bit
     digitalWrite(DATAB,HIGH); // send 1
    }
    else{
     digitalWrite(DATAB,LOW); // send 0
    }
    delayMicroseconds(bit9600Delay);
   
    digitalWrite(CLOCKB,LOW);
   
    if (data & mask){ // choose bit
     digitalWrite(DATAB,HIGH); // send 1
    }
    else{
     digitalWrite(DATAB,LOW); // send 0
    }
    delayMicroseconds(bit9600Delay);
  }
 
 
  //stop bit
  //digitalWrite(tx, HIGH);
  digitalWrite(STROBB,HIGH);
  delayMicroseconds(bit9600Delay);
  digitalWrite(STROBB,LOW);
}


void loop()
{   // the exemple sequence from the page 47 of the datasheet          http://www.datasheetcatalog.org/datasheets/50/338893_DS.pdf
    dataAPrint(n4);
    dataBPrint(n4);
    dataAPrint(n3);
    dataBPrint(n5);
    dataAPrint(n2);
    dataBPrint(n6);
    dataAPrint(n1);
    dataBPrint(n7);
    dataAPrint(n0);
    dataBPrint(n7);
    dataAPrint(i1);
    dataBPrint(n7);
    dataAPrint(i2);
    dataBPrint(n6);
    dataAPrint(i3);
    dataBPrint(n5);
    dataAPrint(i4);
    dataBPrint(n4);
    dataAPrint(i5);
    dataBPrint(n3);
    dataAPrint(i6);
    dataBPrint(n2);
    dataAPrint(i7);
    dataBPrint(n1);
    dataAPrint(i7);
    dataBPrint(n0);
    dataAPrint(i7);
    dataBPrint(i1);
    dataAPrint(i6);
    dataBPrint(i2);
    dataAPrint(i5);
    dataBPrint(i3);
    dataAPrint(i4);
    dataBPrint(i4);
    dataAPrint(i3);
    dataBPrint(i5);
    dataAPrint(i2);
    dataBPrint(i6);
    dataAPrint(i1);
    dataBPrint(i7);
    dataAPrint(i0);
    dataBPrint(i7);
    dataAPrint(n1);
    dataBPrint(i7);
    dataAPrint(n2);
    dataBPrint(i6);
    dataAPrint(n3);
    dataBPrint(i5);
    dataAPrint(n4);
    dataBPrint(i4);
    dataAPrint(n5);
    dataBPrint(i3);
    dataAPrint(n6);
    dataBPrint(i2);
    dataAPrint(n7);
    dataBPrint(i1);
    dataAPrint(n7);
    dataBPrint(i0);
    dataAPrint(n7);
    dataBPrint(n1);
    dataAPrint(n6);
    dataBPrint(n2);
    dataAPrint(n5);
    dataBPrint(n3);
    dataAPrint(n4);
    dataBPrint(n4);
   
}

Grumpy_Mike

This is better:-
http://arduiniana.org/libraries/newsoftserial/

Is there any reason you are not using the library to do this?

If it is to learn then you should only deal with one unknown at a time. You are trying to do serial communications and you are trying to drive a stepping motor.
I don't see how those two are linked as the stepping motor chip uses SPI serial data and your code appears to be asynchronous serial data, the two are very different things.

miette

hi , Thank you Grumpy_Mike
i didn t knew the arduiniana library
i will look at it and try to understand

for the stepper , i tried with l293 (on breadboard) with success , then try with the adafruit motor shield , with success
then i made a custom version of the adafruit motor shield wit l298 instead of l293 with success

but the common problem i have each time is a huge overheat in few seconds because of the motors i am using

so i thought about using the original drivers from the printers

but i am a beginner and serial communication is really difficult , i don t even understand SPI serial data  and asynchronous serial data

if it too difficult i will make another custom motor shield board with some sla7026m that i just found about on the forum


do you have any other advice , or information i might have missed about communicating in serial with that component

thank you for your answer


Grumpy_Mike

Quote
i don t even understand SPI serial data  and asynchronous serial data

See:-
http://en.wikipedia.org/wiki/Asynchronous_communication
http://en.wikipedia.org/wiki/SPI

Quote
have each time is a huge overheat in few seconds because of the motors i am using

This is because the current is too high. Two solutions:-
1) Use a lower voltage.
2) Use a stepping driver that regulates the current like this one. http://www.pololu.com/catalog/product/1201


miette

thanks i did read http://en.wikipedia.org/wiki/Asynchronous_serial_communication and http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus

it is still difficult to understand fully , my case seems to be more like SPI cause of the clock , so i guess every serial component such as 74hc595 or max7221 are SPI
whereas  this tutorial http://www.arduino.cc/en/Tutorial/SoftwareSerial is for asynchronous serial communication

thank you for showing me the current regulator motor driver (i wont use a lower voltage , i want to keep the max torque)

i have now to choose between this and a custom sla7026 motor shield

thanks Grumpy_Mike


if anybody wants to explain me what s wrong in my code it would be appreciated (because i am still interested in learning from my mistakes)
and if it is just the timing , how should i deal with the doc information

thanks 

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy