program to run motor.

Discussion of the PSoC Creator Integrated Development Environment for PSoC3 & PSoC5 devices.

Moderator: ericb

program to run motor.

Postby arivalagan13 » Mon Jan 28, 2013 8:36 am

hi,
following attachment includes a program designed by us to run a motor... as per our view, it should rotate both fwd and rvse direction with delay.... After delay it should jump into the next condition for the reverse direction.... but the motor is rotating only for the 1st condition.... it is not responding for the delay and 2nd condition. Wat will be the problem? pls check our program? is there any modification needed?
Attachments
swmotor.rar
pls check and do help us
(121.99 KiB) Downloaded 154 times
arivalagan13
Cheese Wheel
Cheese Wheel
 
Posts: 129
Joined: Sun Dec 23, 2012 3:32 am

Re: program to run motor.

Postby bobmarlowe » Mon Jan 28, 2013 10:16 am

There is a feature in Creator (in Designer, too) to archieve a project which will ensure to have a format everybody can handle.
Will you kindly use that?

Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: program to run motor.

Postby danadak » Wed Jan 30, 2013 4:58 pm

Change your code to this -

Code: Select all
#include <m8c.h>        // part specific constants and macros
#include "PSoCAPI.h"    // PSoC API definitions for all User Modules
void main(void)
{
    WORD i;
   PRT2DM0 = 0xFF;
    PRT2DM1 = 0x00;
    PRT2DM2 = 0x00;
   
   // M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts

   while ( 1 ) {
   
      PRT2DR = 0x20;
      for(i=0;i<40000000;i++)   { };
   
      PRT2DR = 0x02;
      for(i=0;i<40000000;i++)   { };
      PRT2DR = 0x00;
   }
}


You fell out of main because you were not in a loop, so it stopped after the third command was
issued. Also I cannot tell which port pins you are driving because you did not give them a name.
Are you sure the pins you are driving are the right pins, 0x20 is Port 2 Pin 5, 0x02 is Port 2 Pin 1.
Lastly in the loop the last command is not needed "PRT2DR = 0x00;", if you want to run this in a
loop.

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: program to run motor.

Postby arivalagan13 » Thu Jan 31, 2013 12:48 am

Thank u friend for ur response.......i'm going through it.....will soon respond with the result.. :)
arivalagan13
Cheese Wheel
Cheese Wheel
 
Posts: 129
Joined: Sun Dec 23, 2012 3:32 am

Re: program to run motor.

Postby arivalagan13 » Thu Jan 31, 2013 2:46 am

hi,
we tried for that program too, but it's giving the same response as before...... still it's not entering into the 2nd statement (PRT0DR = 0x02;, for reverse direction)..
i'm using CY8CKIT-001 PSoC® Development Kit and 0x20 in Port 0 Pin 5, 0x02 in Port 0 Pin 1.. what should be my next step...? whether i want to change the program?
arivalagan13
Cheese Wheel
Cheese Wheel
 
Posts: 129
Joined: Sun Dec 23, 2012 3:32 am

Re: program to run motor.

Postby danadak » Thu Jan 31, 2013 4:22 am

I see the problem, you declare

Code: Select all
    WORD i;


but then your for loop test

Code: Select all
      for(i=0;i<40000000;i++)   { };


is testing for a value > WORD ( > 65535 ). Either declare

Code: Select all
LONG i;


or test for < 65536.

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: program to run motor.

Postby arivalagan13 » Thu Jan 31, 2013 7:07 am

thank u dana............... i'l try for that and intimate u soon....
arivalagan13
Cheese Wheel
Cheese Wheel
 
Posts: 129
Joined: Sun Dec 23, 2012 3:32 am

Re: program to run motor.

Postby arivalagan13 » Fri Feb 01, 2013 7:21 am

thank u friend :) v solved the problem and run the motor... i attached the modified program... thanks a lot for ur response..... :D
Attachments
motorpgm.rar
(134.52 KiB) Downloaded 143 times
arivalagan13
Cheese Wheel
Cheese Wheel
 
Posts: 129
Joined: Sun Dec 23, 2012 3:32 am

Re: program to run motor.

Postby arivalagan13 » Sun Mar 10, 2013 4:32 am

Hello all,
I read from AN2094(i listened to the video associated)...

I understood that if i configured my input and output pins of the same port,
then i should write to the output port through shadow registers...
Should i do the same thing if my input and output pins are in different pins?

I ask this coz of my recent experience...
I interfaced a motor to PSoC1 through L293D(and tried with ULN2003 as well) and written control data to run the motor..
(will attach the project soon as i have some access problem now)
The motor do run but slowly the PSOC1(29466 on PSOC1 eval board) gets heated... but as soon as power is turned-off it gets cool gradually....

also once the motor is switched on and motor is running, am not able to switch-off PSoC1 power through PSoC1 programmer window and i have to switch-off motor power and then i have to switch-off PSoC1 power?

Donno why it is happening..
This is really disguisting especially am in the critical phase of my project work..

Kindly support friends..

Regards
Arivalagan M
arivalagan13
Cheese Wheel
Cheese Wheel
 
Posts: 129
Joined: Sun Dec 23, 2012 3:32 am

Re: program to run motor.

Postby bobmarlowe » Sun Mar 10, 2013 4:45 am

Can you provide us with a schematic of the connected interface and motor? Probably there is a connection between the motor-power and the PSoC power.

Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: program to run motor.

Postby danadak » Sun Mar 10, 2013 4:47 am

Shadow registers handle read modify writes for mixed I/O
in the same port.

Sure sounds like motor transients are latching up PSOC, which then
cause PSOC to malfunction, and draw a lot of current, hence getting
hot.

29466 latchup current is speced at 200 mA, which translates to 1W for
Vdd = 5V, part would get very hot to touch.

Key to latchup is a transient on a pin that exceeds Vtrans >= Vdd or
Vtrans <= Vss, eg any pin taken more than a diode drop from either rail will
trigger latchup.

So you have to pay a lot of attention to ground bounce due to motor current,
and bypassing for PSOC, and transients on GPIO pins. Layout, split grounds,
capacitive feedthru back thru drivers, all cause these problems.

Pay attention to bulk bypass capacitor specs, some do NOT have good ESR vs freq
characteristics. Good quality caps, like polymer tantalum, and MLC ceramics,
worth their weight in gold.

Also power supply sequencing, generally UP supply must come up first, shutdown
last with respect to motor supply and its driver.

This ap not, written for PSOC 3/5, certainly applies to PSOC 1 considerations
as well.

http://www.cypress.com/?docID=41175

and this -

http://ww1.microchip.com/downloads/en/AppNotes/00763c.pdf

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: program to run motor.

Postby arivalagan13 » Wed Mar 13, 2013 10:50 am

hi,
thanks dana.. i got ur point.. to solve tis i planned to put a bypass capacitor between +vs and -vs... but since i'm using PSOC1 evaluation kit where i wanna place the capacitor... can u give me some more ideas to solve this?
arivalagan13
Cheese Wheel
Cheese Wheel
 
Posts: 129
Joined: Sun Dec 23, 2012 3:32 am

Re: program to run motor.

Postby danadak » Wed Mar 13, 2013 1:14 pm

Think of two loops of power, one the PSOC and the rest of the stuff
on PSOC board, the other the motor plus its drivers.

In the first loop the PSOC board is already fairly well bypassed, that's
how Cypress gets 20 bit performance out of its A/D.

The two loops each have a potential supplying them, and under best
situation that V+ for each is separated, eg. there is a separate V+ for
board, and a separate one for the the motor.

The two loops have to touch at ground, in order for logic levels and signals
to have a common reference. That junction should be at main ground entry
into board. You can see this on schematic and/or PCB layout doc that comes
with kit. Note that junction is two components for board, and one for motor.
Analog gnd, Digital gnd, and motor driver ground.

So start with motor and its driver, and using scope, and drawing out the high
current path in your jig, try bypass placement and observe on scope if it is making
a difference.

This is a visualization exercise and tack and try methodology. Its 75% art, 25% science.

One other thing, any HiZ input on PSOC loves an E field component, especially
stuff produced by motor currents inducing drops in conductors. So either drop Z at
input with terminating R's (not great, burns power) or make sure distance to e and/or
m field generator is large. Motors, as one might expect, make big m fields, so inductive
coupling, like a single turn in a trace, make good transformers when you don't want them.
Layout is everything.

Lastly you have minor loops, the logic signals going to the drivers. Coupling here is
to be avoided, to other pins.

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: program to run motor.

Postby arivalagan13 » Mon Mar 18, 2013 10:02 pm

The problem is now solved..after using appropriate capacitors..
Thanks all
arivalagan13
Cheese Wheel
Cheese Wheel
 
Posts: 129
Joined: Sun Dec 23, 2012 3:32 am


Return to “%s” PSoC Creator (PSoC3 & PSoC5 IDE)

Who is online

Users browsing this forum: No registered users and 4 guests

cron