You are here

Cypress Maker Lab - Barc Go! Barc Stop! Barc Chase Your Tail! | Cypress Semiconductor

Cypress Maker Lab - Barc Go! Barc Stop! Barc Chase Your Tail!

It's time for the finishing touches on Barc's motor control circuit. It's high time I took notice of the motor driver FLT (fault) signal and I want to add the ability to walk backwards.

I started by tidying up the wiring on the breadboard. Sree was giving me some mean looks about it. Here is the neater layout with the PSoC moved closer to the driver board and the wires running underneath where the two board plug in.

Barc robot dog - new wiring Barc robot dog - new wiring with kits

I thought the FLT signal would be easy. The documentation says that it is normally high and drives low if there is an over-voltage or over-heating problem in the driver chip. So I figured I could just AND the SLP (standby) and FLT. This should automatically turn off the motors if the FLT goes low. This would be another example of how flexible PSoC is and I drew up this circuit.

Barc robot dog - Using the FLT pin

I thought this looked really neat and made the fault protection really robust because it is in hardware, with no risk of an interrupt getting masked or anything naughty like that. There was just one problem. It doesn't work. The motors don't run. So I messed about with the circuit. I questioned my logic. I checked signals by wiring them to the LED. I questioned my sanity. And then I gave up and called my mate Sree. Sree is a real engineer and has a super-power I shall never possess. He can be bothered to read the documentation. I had burned most of my Sunday on this. Sree figured out over lunch that, when you enable the motors (via SLP) the FLT signal always drops low for 380 microseconds. Now, if I am honest, it actually took Sree about 3 minutes to find out the problem and the rest of lunch was taken up with me moaning about hardware and how much easier it would be to do this with software after all. But the end result didn’t change - my circuit cannot work.

I need to enable SLP, wait a while, and then start worrying about FLT. I was mulling over a plan of using a second counter to start timing when the button is pressed and sample FLT after 380us. But it seemed like overkill for the actual problem and I did not like that it meant we would be running the motor without checking FLT, even if it was for a really short period of time. Ideally I wanted to turn on SLP but keep the AIN and BIN signals low (so no load was put on the motors) until FLT was ready to be read and was high. Enter the PWM kill signal. The PWM I am using to drive the motors has an optional kill input which sets the outputs low when the kill is high. This is a really easy way to protect the motors. Press the switch and enable the motors with the PWMs killed. As soon as the FLT goes high the PWMs start. This is a really elegant solution that does not require an extra counter or make any assumptions about how long the delay on the fault signal is. I programmed it into Barc and tested that FLT does, indeed, stop the motors by wiring it up to ground before and after pressing the switch.

Barc robot dog - FLT pin KILL on PWM

I feel a lot safer now. With Embedded World just a few days away I am less likely to blow up my demo! Let's add some maneuverability to this hound. I can go forward, left and right, but I cannot reverse or spin on the spot. Real dogs are pretty good at that. I need to be able to switch the PWM outputs to the AIN and BIN pins. I am going to do that by using a control register. This is an 8-bit register (I only need 2 bits) that lets me set hardware signal from firmware. Each bit shall define the direction of the motor and, in the schematic, I will simply use some more AND gates to send the signal to the desired pin. Pictures are worth a thousand words, so here is my circuit, starting with the control register, which I have called Direction.

Barc robot dog - control register

Note how I have named the wires to make the drawing easier - it helps to see what is going on that way too. The PWM outputs get ANDed with the direction signals to either hold the pin low or pass through the PWM signal. Note that I re-enabled the HW connection on the AIN2 and BIN1 pins so I can connect them to the gates (and I no longer set them from firmware).

Barc robot dog - control register for direction and PWM for speed

A little splash of firmware and we have a dog that can walk forwards and backwards and chase his tail in both directions.

#include "project.h"

int main(void)

{

    uint8 dir = 0;

    CyGlobalIntEnable;

    for(;;)

    {

        Direction_Write( dir++ );

        CyDelay( 1000 );   

    }

}

 

I am happy with Barc's agility now. He is nearly ready for the big dog show in Germany! Just one last problem to solve . How to make him "see" people and interact with them. This sounds like a big task, but PSoC's CapSense makes this quite simple… next time.

 

Comments

laorilearner_2527786's picture

What are the directions, if the control stability item is changed? CapSense isn't always working well for such tools as Editorpaper, cheap essay or ReadMeon.

csjoshi.editsoftdigital_2593831's picture

More About the Concept of an Afterlife: The only part of you that could in any way survive into an afterlife would have to be an immaterial part of you since when you snuff it, your material remains go nowhere. But any immaterial part of you would have no sensory apparatus so how could you enjoy an afterlife when you couldn't experience it? On the other hand, if your life is but a computer simulation, then equally so could your afterlife be another simulation. One software program ends (death) and another begins (afterlife).

nishgau28_2730811's picture

I love to play games on playstation as it is very interesting and exciting. Playstation codes are available on the mentioned website for free. Grab ps plus codes for psn games and explore all the features on online line psn games.

 

lucychrisan_2813081's picture

PSN is one of the biggest gaming platforms. PSN Network’s services are dedicated to an online marketplace, a premium and paid subscription service for enhanced gaming and social features with wonderful graphics, and get them all here for free, what more you would expect PSN Card Codes Free. Its all available on the single website. Our offers are very easy to complete and within a minute you will be able to earn desired PSN Codes to fulfill your wish to compete in all PlayStation online games. It's amazing to play PSN games online and I would love it to share it with everyone. What if you get PSN codes for free. Yes its real, now its available for free on this very website, Visit to grab these codes. These free PlayStation plus codes and hack for PSN games all are available for free. Have a try 

 

 

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.