Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 1 > Controlling the direction of the motor

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Controlling the direction of the motor
Moderator:
ARVI

Post Reply
Follow this topic



Controlling the direction of the motor

mins posted on 25 Jun 2012 8:17 AM PST
Top Contributor
39 Forum Posts

HI all, i am trying to control the direction of the motor forward or bacward, i am giving out signal, by using DAC from Potentiometer. i am working on KIT number CY8C29466-24 SXI.

If anyone can help me to figure out how to control that would be great.

 

Thanks

 




Re: Controlling the direction of the motor

Bob Marlowe posted on 25 Jun 2012 08:30 AM PST
Top Contributor
1768 Forum Posts

It is always not adviseable to connect an inductance (motor coil) directly to any digital circuit, even when the motor is a very small one. There are interfaces named H-Bridges giving you full control over the direction of the movement, strength (voltage) and torque (with PWM), even the start-stop behaveour may be controlled.

An H-bridge may be made of 4 separate transistors or may be contained in an IC, look here

http://en.wikipedia.org/wiki/H_bridge

Bob

 



Re: Controlling the direction of the motor

mins posted on 25 Jun 2012 09:24 AM PST
Top Contributor
39 Forum Posts

but how i would use H brige on the KIT?

is there anyway to control the signal that i am sending to direction bit, by inverting the bit ?



Re: Controlling the direction of the motor

danaaknight posted on 25 Jun 2012 09:31 AM PST
Top Contributor
1773 Forum Posts

Take a look at this, and references at bottom of page.

 

http://en.wikipedia.org/wiki/H_bridge

 

There are a number of manufacturers that makes H Bridges, which

include thermal and overvoltage, over current protection, and include

the bias pumps to make them TTL compatible.

 

Regards, Dana.



Re: Controlling the direction of the motor

Bob Marlowe posted on 25 Jun 2012 10:01 AM PST
Top Contributor
1768 Forum Posts

The direction is a digital signal which you can control by writing to the corresponding port-bit. Take care of the read-modify-write problem, best use a shadow-register. Look here http://www.cypress.com/?id=4&rID=28251 and here http://www.cypress.com/?rID=39497

 

When you've got a kit there are usually some LEDs on it. You may use the LED-component to switch a port-bit and have it indicated. You even may use this construct to switch the motor-direction.

Bob



Re: Controlling the direction of the motor

mins posted on 25 Jun 2012 12:09 PM PST
Top Contributor
39 Forum Posts

i tried to do it but i failed, if anyone can take a look at it and let me know what i am doing wrong,

 

Thanks



Re: Controlling the direction of the motor

danaaknight posted on 25 Jun 2012 12:31 PM PST
Top Contributor
1773 Forum Posts

Post a schematic of your interface, and wiring to PSOC.

 

Regards, Dana.



Re: Controlling the direction of the motor

danaaknight posted on 25 Jun 2012 12:43 PM PST
Top Contributor
1773 Forum Posts

I did see one error, per datasheet both MSB and LSB must have the same column clock per the

following note in datasheet -

 

"An additional consideration, in selecting a placement location, is that the MSB and LSB clocks must be derived from the same source. This happens automatically, if they are placed in the same column in the analog array. If they are placed in two different columns, both column multiplexers must be set to the same source."

 

Regards, Dana.



Re: Controlling the direction of the motor

Bob Marlowe posted on 25 Jun 2012 01:18 PM PST
Top Contributor
1768 Forum Posts

I put some suggestions into your code, watch out for ********* markings.

 

Bob



Re: Controlling the direction of the motor

mins posted on 26 Jun 2012 08:59 AM PST
Top Contributor
39 Forum Posts

sorry for bothering, but i am new with the PSOC, can you look at it and let me know how to get out the loop, because it doesnt detect the switch when its on/off. and stuck in one direction.

 

Thanks

 



Re: Controlling the direction of the motor

Bob Marlowe posted on 26 Jun 2012 11:06 AM PST
Top Contributor
1768 Forum Posts

Since it is not 100% clear to me what signals you exactly expect I made a digital approach at first.

I generated one signal for the direction and one for motor on/off. You may turn the second signal at need into a PWM to control the motor speed.

 

Happy coding

Bob



Re: Controlling the direction of the motor

Bob Marlowe posted on 26 Jun 2012 11:09 AM PST
Top Contributor
1768 Forum Posts

(§&%$!!!) and here's the project - file

 

I WANT TO HAVE AN "EDIT" FEATURE!

 

Bob



Re: Controlling the direction of the motor

mins posted on 27 Jun 2012 11:46 AM PST
Top Contributor
39 Forum Posts

Hi Bob, i used what you sent me and used it in my code but still i am missing something.

so you can understand what i am trying to do in this project. I am using CY8C29466-24 SXI to control a motor unit. i am trying to control the speed of the motor by connecting the potentiometer to input PORT 0-7, and the output speed on PORT 0-5.

Controlling it by swtiches RUN/STOP connected to PORT 0-1 , and CW/CCW ( direction ) to PORT 0-0.

i am trying to be able to change speed while motor is running or while its not running. and by the right direction.

I attached the project, can you take a look at it and see what am i missing in it.

 

Thanks

 



Re: Controlling the direction of the motor

Bob Marlowe posted on 27 Jun 2012 12:26 PM PST
Top Contributor
1768 Forum Posts

You are using the variable "iData" as the loop-control and you are assignig a value to it within the loop, thus the loop will never terminate correctly.

On the other hand I suspect that you are connecting your motor directly to the DAC output of the PSoC which will destroy it immediately!!

Controlling a motor is usually done with a PWM which has a digital output with a varying duty-cycle to control the speed. Although the PSoC is able to drive a few mA to drive a (very) small motor you may NOT connect the motor directly to it because the running motor will create (like a dynamo) voltages that are grater than the allowed 5V and so blowing immediately the protection circuits at the pins.

Before continuing with the programming of your PSoC try to make a schematic and post it here, we'll have a look at it.

 

Bob



Re: Controlling the direction of the motor

mins posted on 27 Jun 2012 01:04 PM PST
Top Contributor
39 Forum Posts

if it will be helpful i will use it, because after i am done with that, i have to capture the time input and compare it to the output capture PRT.

But how i use it ? because i have to vary the input manually using the potentiometer using DAC9 (iData)



Re: Controlling the direction of the motor

Bob Marlowe posted on 27 Jun 2012 01:39 PM PST
Top Contributor
1768 Forum Posts

I am not quite clear what you exactly want do do. English is not my native language, so please be so kind to explain a bit more to me so that I can understand your needs. Helpful for you (and for me) would be a block-diagram to have a look at your concept, so that we are talking about the same thing.

 

Bob



Re: Controlling the direction of the motor

mins posted on 27 Jun 2012 01:51 PM PST
Top Contributor
39 Forum Posts

ok, i attached my diagram. basically i have two digital inputs, one for power and other for direction. and the output will be for enable to let motor run, direction, speed, and monitor back the timer input capture which take it and compare the frequency of it to the output RPM frequency. i control the speed by Potentiometer.



Re: Controlling the direction of the motor

Bob Marlowe posted on 27 Jun 2012 02:04 PM PST
Top Contributor
1768 Forum Posts

OK, I think I understood. Will be back tomorrow (it's here 23:00h)

Bob



Re: Controlling the direction of the motor

Bob Marlowe posted on 27 Jun 2012 09:38 PM PST
Top Contributor
1768 Forum Posts

Since you are using a PSoC1 and you did not tell us about having got an ICE (In-Circuit-Emulator) you will have to set up a minimum man-machine-communication to get a little bit of insight what is going on within your chip. The minimum is a couple of LEDs you may turn on or off, if your kit has got an LCD-module, you can use that.

Best will be to work in little steps, realizing one block after the other, testing it and integrating it. Sometimes it will be easier to build a part of the project separately, get it tested and then integrate it into the project (and test it again).

Since you still have to learn some programming skills, best is to frequently upload your project here, so that we can have a look at and having something solid to diskuss on.

So at first i suggest you to set up your test-environment (LEDs/LCD).

then Connect your input-signals and verify each of them getting seen in your program

Connect your output-signals and see that you can set them progammatically.

DOCUMENT ALL CONNECTIONS !!!

Since we have to read your program, try to make it look easy, use names that speak for themselfs (iData is not as good as ADC_Value), use clear indentation and comments to explain what you're doing. Using function calls makes the whole project easier to overlook and even may save precious RAM: using a function as "void InitializeHardware(void)" and calling this from main() will show where all related stuff has to go to and shortens main() to the very essential part.

Happy coding

Bob



Re: Controlling the direction of the motor

mins posted on 29 Jun 2012 06:25 AM PST
Top Contributor
39 Forum Posts

Hi Bob, i attached the file.

i tested the switches seprate with LEDs and they were function right, but when i put the code in my project, it is not function all correctly. i think because i always getting data from ADC. can you take a look at it. now the problem are when i switch to Stop, it doesnt decrease the speed till Zero as it should do. it just stop the motor. and when i switch to Run mode, it starts as iData value is. not speeding up from zero up to the value as it should be doing.

can you advice me in that ?

Thanks



Re: Controlling the direction of the motor

Bob Marlowe posted on 29 Jun 2012 08:46 AM PST
Top Contributor
1768 Forum Posts

Have a look at that, maybe you can start from that...

 

Bob



Re: Controlling the direction of the motor

mins posted on 03 Jul 2012 06:26 AM PST
Top Contributor
39 Forum Posts

hi Bob, can you help me more to figure out what am i doing wrong or what should i use to solve it, i looked at code you sent me, and i donot think it will help me, because i have to control the motor my switches, RUN/STOP, and direction CW/CCW.

Thanks



Re: Controlling the direction of the motor

mins posted on 03 Jul 2012 08:26 AM PST
Top Contributor
39 Forum Posts

Here is the code, the thing is that it stuck in the while loop, i dont know how to get the motor react when i change the switch.



Re: Controlling the direction of the motor

Bob Marlowe posted on 03 Jul 2012 10:59 AM PST
Top Contributor
1768 Forum Posts

The code I supplied acted on your RUN and CW switches, but probably you didn't see how.

Your learning curve for C-programming seems to be at the beginning, so a couple of hints you should obey:

Declare variables in the functions where you need them. Do not use global (outside of main() ) vars, they open the door for unwanted side-effects.

Have a look at the meaning of "static" storage-class

You are not yet thinking binary: you defined RUN as 0x02 and STOP as 0xfd (which would have been better declared as ~RUN)

First if(POWER & RUN) which will result in the binary AND and will give a correct result.

Second if(POWER & STOP) which will result in the binary AND of PORT0DR and 0xFD which you do not want.

so, it is (POWER & RUN) for running condition and !(POWER & RUN) for stop condition. Follow the logic my example shows.

The same applies for your CW/CCW-logic.

Turning on and off a bit of an I/O_port as you have started by defining your LED-constants will not act as expected. for beginners I would suggest to use the LED-Component and the LED_On(), LED_Off() APIs.

 

Bob



Re: Controlling the direction of the motor

danaaknight posted on 04 Jul 2012 05:14 AM PST
Top Contributor
1773 Forum Posts

Some additional thoughts on variables, first a summary of static vs global -

 

Global variables are variables defined outside of any function. Their scope starts at the point where they are defined and

lasts to the end of the file. They have external linkage, which means that in other source files, the same name refers to the

same location in memory. Static global variables are private to the source file where they are defined and do not conflict

with other variables in other source files which would have the same name.

 

I use globals outside of main(), ones that are used thruout code base, because generally speaking lessens copying

operations inherent in variable passing. Especially structures that are at heart of program. Also I use pointers to globals to

limit copying. These have the significant advantage code size reduced, especially for variables not machine native, like

longs and floats. And speed advantage, the less copying the more MIPS for other needs.

 

Regards, Dana.



Re: Controlling the direction of the motor

mins posted on 05 Jul 2012 06:06 AM PST
Top Contributor
39 Forum Posts

Hi Bob, yes i looked at your code and i did the same concept, but my problem is when i try to use a switch, it get stuck in the first loop and never come out from it, so what should i use to make it exit out the loop condition (POWER&CW) to go to (!(POWER&CW) for example?

also i want to speed up untill it gets to POT value in a slope like increase slidelly. and when i switch to different mode, i want it to decrease slidlly to zero then increase slidelly.

Take a look at what i have been done and let me know.

Thanks



Re: Controlling the direction of the motor

Bob Marlowe posted on 05 Jul 2012 07:12 AM PST
Top Contributor
1768 Forum Posts

Looked over your file and left comments with ****

 

Bob



Re: Controlling the direction of the motor

mins posted on 05 Jul 2012 09:13 AM PST
Top Contributor
39 Forum Posts

i fixed it, and it works with CW/CCW but once i switch to STOP, it stops the motor but doesnt go to my else function.



Re: Controlling the direction of the motor

mins posted on 05 Jul 2012 11:12 AM PST
Top Contributor
39 Forum Posts

thats the updated one, the STOP condition still not function right. it should be anytime i switch to stop (!(POWER&RUN)) should increase to the POT value. not resume the iData.



Re: Controlling the direction of the motor

Bob Marlowe posted on 05 Jul 2012 11:55 AM PST
Top Contributor
1768 Forum Posts

It is now the third time i make some corrections at the very same places, you did not take the all the advices I gave you, you did not correct the timer clock and period..... you must be a bit more precise.

Take a look at this. As a hint: everything that occurs more than twice in the code is often something that can be optimized.

And have a look at the two new macros.

 

Bob

 



Re: Controlling the direction of the motor

mins posted on 06 Jul 2012 07:56 AM PST
Top Contributor
39 Forum Posts

Hi Bob, i am sorry but i tried the way you told me and didnt function like it should be thats why i kept everything the way it was.

in the Code you sent me last, it only function with one direction, its not working when i switch direction or when i turn Run to Stop. i tried to get it fix but i dont understand why it doesnt let me.

Thanks for helping.

 

while(forever)if(POWER & RUN)do// Set the Direction outputwhile(ADCINCVR_fIsDataAvailable() == 0) Wait(); // Wait for data to be ready.// Get Data and set motor-speedwhile (( POWER & CW )==1);do // Set the Direction outputwhile(ADCINCVR_fIsDataAvailable() == 0) Wait(); // Wait for data to be ready.// Get Data and set motor-speedwhile ((!(POWER & CW)) ==1 );else0); // set it to zero // set it to zero

 

{

 

{

 

 

{

DirectionPin_Switch(POWER & CW);

 

RunPin_On();

 

 

 

MoveMotor(ADCINCVR_iGetDataClearFlag());

 

}

 

 

{

DirectionPin_Switch(!(POWER & CW));

 

RunPin_On();

 

 

 

MoveMotor(ADCINCVR_iGetDataClearFlag());

 

}

 

}

 

 

{

MoveMotor(

 

DirectionPin_Off();

 

RunPin_Off();

}

}

}



Re: Controlling the direction of the motor

Bob Marlowe posted on 06 Jul 2012 09:35 AM PST
Top Contributor
1768 Forum Posts

As I asked a while ago, can you please supply us with a schematic (Drawinng, picture) of your external connections to the motor (or however you emulate the motor). I think there may be some misunderstanding.

With your supplied code , sorry but this forum-software sometimes is not able at all to handle code correctly there seems a lot to be out of order so I will not comment it.

Bob

 



Re: Controlling the direction of the motor

mins posted on 06 Jul 2012 09:50 AM PST
Top Contributor
39 Forum Posts

i attached the project and how should look like, basically i am controlling a motor through the KIT. i have 2 switches, one is for RUN or STOP the motor which is connected to P01, and other is for CW or CWW to control the direction of the motor connected to P00. i have POT connected to PORT 0-7 and the output to PORT 0-5.

i want to measure the frequency of the speed of the motor and compare the output frequency to the PRM out. so when the switch on RUN, it starts from zero slidly increase until value of POT, and when i switch CW to CCW, the motor's speed should decrease till it gets to zero then switch the direction and then from Zero it starts increase till the POT value,, while the motor is running or stop i can be able to change the value of the POT. and when i switch to STOP, it should decrease the speed to Zero.

if you look at the code that i had and attached, you will see that i want to get control of the speed by incrementing the speed or decrement the speed and also switches and be able to change the value of the POT while its running, may be that why i was keep using my code because i am almost there just little bugs.

please look at the attachments.

 

Thanks



Re: Controlling the direction of the motor

Bob Marlowe posted on 06 Jul 2012 10:25 AM PST
Top Contributor
1768 Forum Posts

Now with the diargam there is a lot more clear to me! I'll come back with some more info later.

Boib



Re: Controlling the direction of the motor

mins posted on 06 Jul 2012 10:46 AM PST
Top Contributor
39 Forum Posts

Great, and here is my lastest code i have.

Thanks Bob



Re: Controlling the direction of the motor

Bob Marlowe posted on 06 Jul 2012 11:52 AM PST
Top Contributor
1768 Forum Posts

So, back again. The drawback of the software design used is that during the slow-down or accelerate of the motor the switches and poit are not read. When principially the design runs, you should update the DAC in an interrupt-routine independently. Since your schematic shows a tach-input I suppose you'll implement a closed-loop to control the motor-speed.

What is the reason to slope the motor-speed? Is that not done by the interface? Are you going to use the break-input?

Bob



Re: Controlling the direction of the motor

mins posted on 10 Jul 2012 08:51 AM PST
Top Contributor
39 Forum Posts

we need the slope becasue the project requires to make motor slow down till reach zero, or start from zero and speed up till it reaches to the POT value. yes we will use the break-input but that will be the last thing i will do.

after i get motor function right with the switches, i have to figure out how to measure the frequency of the motor compare to the input frequency.



Re: Controlling the direction of the motor

Bob Marlowe posted on 10 Jul 2012 09:12 AM PST
Top Contributor
1768 Forum Posts

There is a Tach-Timer usermodule which can be used in measuring the speed of a motor. This tends to start into something like a control-loop calculating (Must-Is) * Factor to change the speed...

 

Bob



Re: Controlling the direction of the motor

danaaknight posted on 11 Jul 2012 03:07 AM PST
Top Contributor
1773 Forum Posts

Although PSOC 3 oriented some techniques for motor control videos

here -

 

http://www.cypress.com/?rID=60521

 

Regards, Dana.



Re: Controlling the direction of the motor

mins posted on 17 Jul 2012 11:17 AM PST
Top Contributor
39 Forum Posts

i dont think the code that you sent is helping me, i want to control the speed by incremting or decreamnting untill it get to the value of the POT, but i have to check first if it is in RUN mode then if it is CW or CCW then change direction of motor then increament the speed of the motor, and once it is on STOP mode, it wont matter CW or CCW so it will decreament till Zero.



Re: Controlling the direction of the motor

arvi posted on 18 Jul 2012 11:33 PM PST
Cypress Employee
119 Forum Posts

 Hi,

For a guide to controlling and measuring fan speeds, you can have a look at PSoC® 1 - Intelligent Fan Controller. The document and example project will help you count the tach pulses and you can drop in the equations to convert them to RPM.

 

If at all you need more resolution for controlling the speed of the motor, you can consider using a 16-bit PWM usermodule, instead of DAC. You will find these details in the appnote as well.

 

Regards,

Arvind



Re: Controlling the direction of the motor

mins posted on 19 Jul 2012 09:03 AM PST
Top Contributor
39 Forum Posts

Hi Bob,

the modified code that you sent me is not function when i change the switches, once it goes to RUN and one of the direction CW or CCW, it gets stuck. i am not sure if i am missing something.

Thanks



Re: Controlling the direction of the motor

mins posted on 19 Jul 2012 09:14 AM PST
Top Contributor
39 Forum Posts

it never comes out from for loop in the MoveMotor function



Re: Controlling the direction of the motor

arvi posted on 20 Jul 2012 11:40 PM PST
Cypress Employee
119 Forum Posts

 Try replacing DAC9_WriteStall(x); with  DAC9_WriteBlind(x);

WriteStall might have some problems if interrupts are enabled and the latency is high.



Re: Controlling the direction of the motor

Bob Marlowe posted on 20 Jul 2012 02:24 AM PST
Top Contributor
1768 Forum Posts

mins,

as someone lately said:"We can show you how to catch fishi, but we will not give you any fish".

When the program stays within a loop, try to find out why and alter the loop accordingly, we here do not have got the hardware you have got to test everything. As I could see, your programming skills are not yet fully developed, and you need a bit more practice. I would recommend  for syntax of C using this http://publications.gbdirect.co.uk/c_book/ book.

Since you are working with PSoC1 and you do not have got an ICE-Cube (In-Circuit-Emulator) it is very difficult to find out the reason if something goes wrong.

The PSoC3 and PSoC5 developement kits are equipped with a built-in debugging-feature (breakpoints, watching variables etc.) so to make your life easier i would suggest:

 

Buy yourself an ICE-Cube. Expensive, but it can show what goes on in your chip. Comes together with a pod for a CyC29466DIP

or

Buy a Kit-050 (cheaper) and develop / debug your software-modules there. That will teach additionally to write hardware-independant code. When the software runs, transfer the source to your target-PSoC.

 

Bob

 



Re: Controlling the direction of the motor

H L posted on 20 Jul 2012 04:14 AM PST
Top Contributor
679 Forum Posts

 As Bob mentioned. it would be much better to have a proper debugging tools for development.

If that is not possilbe. One thing you can do is condigurate a UART and with a 232 interface, use priftf type message to a PC.

insert putstring or putchar in your program so you can see it from the PC hyperterminal.

I would also suggest you to do one little step a time

1. make sure you can control the speed of the motor with a fixed speed.

2. make a simple loop that increase or decrease the speed SLOWLY.

3. Make a loop that can change direction and change speed.

4. Generate pseduo sequence, ie make 1 sec up to 1/2 speed. 2 sec to reverse full speed...

5. Write code to read button correctly with debounce.

6. Combine that together.

Doing it one small step a time would save you time in the end..

 

 

 



Re: Controlling the direction of the motor

mins posted on 20 Jul 2012 05:51 AM PST
Top Contributor
39 Forum Posts

my only problem in my code is, once i change the switch from CW to CCW, it turns direction right away ( it should wait till the speed slow down to zero then turn direction then speed back up again)..

i have CY3215- DK and i debugged code, but i only asked for how to make the bit dont change and wait till speed goes to zero.

Thanks anyway for help

 



Re: Controlling the direction of the motor

H L posted on 21 Jul 2012 06:17 AM PST
Top Contributor
679 Forum Posts

1. Do not to use the CW and RUN direcly from the port, If those are key switches, it should be debounce. 

2. A static variable in main is no use.

3. you should only need to read the pot value once per loop.

4. Do you have some kind of flow chart or state diagram before you start the program, is the program same as your desing?

By the look of it, it seems to be a student project.

It is OK to ask people to have suggestions.

I know some teachers would go around to check if students are getting others to finish their homework. I saw that happended in other forums.

 

 



Re: Controlling the direction of the motor

Bob Marlowe posted on 21 Jul 2012 08:11 AM PST
Top Contributor
1768 Forum Posts

@lleung

A static var in main() has a deep sense!

Any variable in a function (and main() IS a function) would be allocated on the stack, thus reducing it permanently because main() never ends. An alternative would be to define those vars globally, but then they would be accessable from any function, even by accident. Loop-vars needed in main() should NEVER be global, imagine the effort to find the error when a loop-variable is used in two different functions!

Declaring a variable within a function as static reduces the scope of the var to this function, but does not allocate it on the stack !

 

Bob



Re: Controlling the direction of the motor

H L posted on 21 Jul 2012 08:55 PM PST
Top Contributor
679 Forum Posts

Good point Bob.

It does help for 8051 and M8C which has a small stack.

Cheer:

 

 

 



Re: Controlling the direction of the motor

H L posted on 21 Jul 2012 08:57 PM PST
Top Contributor
679 Forum Posts

I agree that we should avoid using global vaiable as well.



Re: Controlling the direction of the motor

danaaknight posted on 22 Jul 2012 03:47 AM PST
Top Contributor
1773 Forum Posts

Globals are not all bad :)

 

I have an application in which several functions access a number of globals by intent,

almost all via pointers, variables are double. Saves a lot of FLASH, code space, by

using pointers to them. Variables not gettting passed on stack, code space and speed

conserved.

 

Hmmmmm, globals are good, when properly used.

 

Note machine architectural width affect efficiency of the above approach. So 8 bit

globals barely get any savings at all in PSOC 1/3 using the above approach.

 

Regards, Dana.

 

 



Re: Controlling the direction of the motor

mins posted on 23 Jul 2012 10:52 AM PST
Top Contributor
39 Forum Posts

hi all, does anyone know how to change the direction of motor once the speed hit zero... it should works like motor is running, and once change dir switch should ramp down to zero -> change direction of motor -> ramp up to speed input.

thanks



Re: Controlling the direction of the motor

H L posted on 23 Jul 2012 05:49 PM PST
Top Contributor
679 Forum Posts

May be you should do in one step a time

Use speed = 0x7f; //half speed.

Check the working of hardware first. Do not detect the buttons, just hardcode as following 3 tests.

1. Check if can work with CW direction

set dirrction to CW

while (1)

{

    slow down motor

    ramp up  motor

}

2. Do the same with direction set to CCW.

3.Check if can work for both direction: 

Change the loop as following

while (1)

{

   direction = CW

    slow down motor

    ramp up motor

   slow down motor

   direction = CCW

    ramp up motor

   slow down motor

}

Check the above first, come back with your result

 



Re: Controlling the direction of the motor

mins posted on 24 Jul 2012 11:19 AM PST
Top Contributor
39 Forum Posts

thanks guys, i got it to work. now i get work on time capture.

 






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20