Interfacing PIC12f629 to arduino

I am trying to inerface PIC with arduino to control huge number of stepper motor I have seen many post on various site and forum for controlling stepper motor with arduino. And arduino is pretty good at it if provide with good shield/Driver. My query is How can is use to arduino control more than 2 stepper motors i.e(64 stepper motor). It seems to be a huge project for me. Each motor will move at same speed but won't have same steps. More like

MIT inFORM

For now we are just making a prototype. I have attached the internal structure of or device where we will be using full stepping mode and only 2 pins for controlling Stepper motor as rest of the 2 pins are just complement of first 2 pins

a b a' b' 1 0 0 1 1 1 0 0 0 1 1 0 0 0 1 1 our basic theory/logic is arduino will generate 2 pulse of each motor pass it to serial to parallel converter and this will further send the pulse to PIC that will generate rest of the 2 pulse and pass it to stepper motor. Each pin on arduino will generate pulse for 4 stepper motor i.e. 8 bit per pin. I will be using 28BYJ-48 stepper and ULN2003 having configuration of stepper motor as 64:1 ratio the thing is at what rate I need to send 128 bits(8 words) of data from arduino to shift register. so the motor should run at decent speed So any one can help us to achieve this and guide us with the project. All reviews are welcome.

|500x282

I don't understand what you mean when you say "Each motor will move at same speed but won't have same steps". If you want them all to run at the same speed why not feed the same step pulses to each of them. That way the computational load would be the same as for a single motor.

I don't understand the flow of information from the PC to the stepper motors.

  • What sort of information will the PC produce?
  • What will the Mega do with that, when it receives it?
  • What data will the Mega send to a PIC?
  • What will the PIC do with that data?

I suggest that ALL of the sequence of pulses for any stepper motor be created by the MCU directly controlling the motor. Sending data across any sort of communications link and expecting it to stay in time is unrealistic unless you are very familiar with what you are doing.

Are all of the motors 28BYJ-48s and is each one controlled by a ULN2003?

I think it would help greatly if you describe the overall project.

...R Stepper Motor Basics

Robin2: I don't understand what you mean when you say "Each motor will move at same speed but won't have same steps". If you want them all to run at the same speed why not feed the same step pulses to each of them. That way the computational load would be the same as for a single motor.

I don't understand the flow of information from the PC to the stepper motors.

  • What sort of information will the PC produce?
  • What will the Mega do with that, when it receives it?
  • What data will the Mega send to a PIC?
  • What will the PIC do with that data?

I suggest that ALL of the sequence of pulses for any stepper motor be created by the MCU directly controlling the motor. Sending data across any sort of communications link and expecting it to stay in time is unrealistic unless you are very familiar with what you are doing.

Are all of the motors 28BYJ-48s and is each one controlled by a ULN2003?

I think it would help greatly if you describe the overall project.

...R

the inFORM link he posted describes the project in great detail, should answer all your questions http://tangible.media.mit.edu/project/inform/

https://vimeo.com/8554267

kinematic sculpture.

find out how they do this, it will answer your questions.

dave-in-nj: the inFORM link he posted describes the project in great detail, should answer all your questions http://tangible.media.mit.edu/project/inform/

From a first look I don't think it will give me the information as easily as a reply from the OP could.

He will need to know it himself to implement the project.

...R

I have re-framed my description and added all the necessary details. Hope it will give you more clear view of our implementation. :slight_smile: :slight_smile:

dendenny01: I have re-framed my description and added all the necessary details.

If you put your original description back and add the extra detail in another Reply after this one I will look at it. But there is no way I am going to try to unscramble my brain to try to bridge the changes between the original post (and my reply to it) and the latest version which probably makes my comments look stupid.

Editing a Post to correct Typos is good. Making major changes is not.

...R

Procedure of Implementation.. I am Extremly sorry for inconvince caused.. Here are the details of my implenation

I am trying to interface PIC12f29 with arduino via serial to parallel converter for controlling stepper motor. Project size 8X8 i.e. 64 motors So our flow is some what this way: And all the motors will have their own UNL2003 Solution 1: - These stepper motor will act as a linear actuator. - Software Running on Pc Will tell how much the actuator has to move up and down -The actuator looks like this

|145x162

-we are using 2 inputs from shift register per motor so in all there will be 4 motors connect per register -Example if there are 4 actuator has to move at level{2,4,8,9}

The software on pc will send 2 Bytes to the arduino Each nibble in the byte will contain the levels detail.Therefore we have 15 distinct level that can be used

Byte1 Byte2 0x23 0x12 0010 0011 0001 0010 2 3 1 2

arduino on receiving this bytes will separate them and put them in a array OutputBufferArray

| 2 | | 3 | | 1 | | 2 | | | - | - | - | - | - | - | - | - | | D | C | D | C | D | C | D | C | | | | | | | | | | | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |

Since we are using 2 inputs to control the motors -First input will be data and 2 will be act as clock -each line in the array will be give to shift register on the other side will be having -PIC to read the data when the clock is High and will finish reading when there is High Pulse on data and Low Pulse on Clock -this pic has a variable to keep track of current position/Level -Assuming each step is of 1 level -This pic will have an array for full stepping like

| 1 | 1 | 0 | 0 | | - | - | - | - | | 1 | 0 | 0 | 1 | | 0 | 0 | 1 | 1 | | 0 | 1 | 1 | 0 | | 1 | 1 | 0 | 0 |

so if the current position is 3 and and the input received was 0010(1) so the sequence it will execute from array is 2 and 1

0 0 1 1 1 0 0 1

and the stepper motor will move to level 1

Solution 2 instead of PIC I can use Inverter IC like 7404 To control the motors will be sending only 2 pulses.As seen in full Stepping out of four pulse 2 are just the complement of the the first two pulses.

| a | b | a' | b' | | - | - | - | - | | 1 | 0 | 0 | 1 | | 0 | 0 | 1 | 1 | | 0 | 1 | 1 | 0 | | 1 | 1 | 0 | 0 |

now instead of Data and clock, shift register will hold 2 data and no clock.This 2 pulse will be the first 2 inputs to motor and other 2 will be given by 7404 IC generate from first 2 two inputs.But the problem is arduino will have to decide everything i.e amount of steps to move for each motors instead of pic where we are just passing the level and pic doing the rest of the task. This is indeed a lengthy procedure. Hope it explains everything..

dendenny01: Procedure of Implementation..

Thank you for your very positive response. I have bookmarked this Thread to study it later today when I have more time.

...R

Ok Sir...

Oh dear - it seems I forgot. Sorry. Will try to look at it later this evening.

...R

Sorry for the delay in looking at your Reply #7

I can understand the PC sending data to the Arduino to indicate the position that each of the 64 motors should adopt. If each byte can hold info for two motors that would mean sending 32 bytes. To be honest, I'm not sure there is any benefit in not sending 64 bytes - unless you need a very rapid update frequency - but you have not told us that.

As far as I can see the PIC12f629 is a small 8-pin microcontroller.

I'm afraid I can't figure from your description exactly what role it will have in all of this, or how many of there will be. You say each motor will have its own ULN2003. Will it also have its own PIC? What will the PIC actually do?

Maybe I am dense but I don't actually know what it is you are asking advice about?

Perhaps if you described how things would work with a single PIC and a single stepper motor ...

...R

I am packing 2 motor infos in 1 byte mainly because to reduce the transmission of packets/Bytes and to increase the refresh rate of each motors

Indeed I have just described the working of single pic. each motor will have their own pic and also ULN2003. I am bit confused with the PIC thing. As the data received by the arduino will be processed and and then given to the respective Pic. Each pic will have an array like this (Full stepping sequence).Assume each step is of 90 degree. The role of pic would be to look at the stepping sequence and make the stepper move to the right level

| Level 0 | 1 | 1 | 0 | 0 | | - | - | - | - | - | | Level 1 | 0 | 1 | 1 | 0 | | Level 2 | 0 | 0 | 1 | 1 | | Level 3 | 1 | 0 | 0 | 1 |

so if the byte received by arduino is 0011 0001 it will send the first nibble to motor 1 and second to motor 2 . the pic1 will receive (3)0011) and pic 2 will receive (1)(0001) now pic1 will look at the current position of the stepper motor lets say position is 1 and received level is 3 so now the pic will execute 2 steps from array to reach position 1

Inshort the PIC will move the motor to desired level received from arduino Actually the procedure is quite complicated. I wanted the advice that should I interface pic or is there any better way to get appropriate result. We are using low cost hardware because of low fund.

dendenny01: so if the byte received by arduino is 0011 0001 it will send the first nibble to motor 1 and second to motor 2 . the pic1 will receive (3)0011) and pic 2 will receive (1)(0001) now pic1 will look at the current position of the stepper motor lets say position is 1 and received level is 3 so now the pic will execute 2 steps from array to reach position 1

Inshort the PIC will move the motor to desired level received from arduino Actually the procedure is quite complicated.

If your description is complete it seems fairly straightforward.

I wanted the advice that should I interface pic or is there any better way to get appropriate result.

This is the bit I don't understand. What do you mean by "should I interface pic"?

...R

I've been thinking a bit more about the first part that I quoted in Reply #13.

I don't seem much point telling the PIC to move one or two steps in the way you propose. I think what you need to do is tell it how many steps it needs to take. Then let the code on the PIC figure out how to do that.

Controlling every individual step of a large number of motors is going to be a challenge for your PC program and the intervening system. Why not design the PC system so it says something like

  • Motor3, go forward 20 steps
  • Motor17, go backwards 80 steps.

or

  • Motor3, move to position 1031
  • Motor17, move to position 87

This is the principle of subsidiarity (greatly favoured by Brussels bureaucrats) - leave the details to be figured out at the lowest level possible.

...R

Sir if Possible can you please provide link or reference to the resource for "Motor3, go forward 20 steps"of And Thanks a Lot sir the Great Help…

I don't have any link for that. I assumed you would know how to write a stepper motor program to move X steps. That seems to be a very fundamental part of your project.

Maybe this Simple Stepper Code will give you an idea. However it for an Arduino, not a PIC. The second example (that does not use delay() ) is much more suitable for a real project. The version with delay() is just suitable for proving a stepper can work.

...R

I agree. The OP's post doesn't make any sense. This is an arduino forum. Why is he talking about PICs ? Why doesn't he go to a PIC forum ?

Question: Why would you use ULN2003s for any application?

The function is essentially obsolete - depending on how much current you wish to drive, a TPIC6A595 can drive 350 mA per output with more than one outputs being simultaneously driven, so has a superior specification. For less demanding current (150 mA), the TPIC6B595.

And being a serial-input shift register, any reasonable number (at least ten) can be driven by only three Arduino (or PIC) outputs outright, so you need far fewer MCU chips to control them.

I'm having a little trouble understanding your intentions. You requested "a link" for how to shift 20 bits. You understand that one input is the data and the other is the clock. What I don't understand is why you are askibg an Arduino forum what to do with a PIC. It doesn't take a genious to figure iut we are going to tell you to "stuff it" ( the PIC). What else would you expect from an Arduino forum ? Why don't you ask a PIC forum what to do with an Arduino ? (what do suppose they are goung to tell you ?) Are we to understand yiu have NO (arduino) software experience ? Are you planning to write the code by asking one question at a time or do you have any plans in the near future to write an Algorithm ? The project you linked is obviously more complicated than shifting 20 bits ( sensors etc.). You said that there are 64 steppers yet you linked a project that had a matrix of at least 30 x ?30 , not 8 x 8. So are you trying to copy the linked projecg on a mucb smaller scale ? Is this your Senior Project or something.? I don't see any use for an 8 x 8 matrix based on the same principal. It would pale in comoarison to the project you linked so what is your reason for doinv this ? (if it is not to try to create a similar effect ?) Is this a school project ?