Log in

View Full Version : Motor Drivers


yash101
13-02-2013, 22:06
Would it be possible to create a SLAVE circuit to the cRIO to control the small servos or even the motors, to prevent lag. I have an eight core processor that I could use to do all the dirty work...Just note, this would be for next year. not this year...no time

yash101
13-02-2013, 22:08
The processor is a P8X32A, in the form of a DIP-40 chip. I will try to migrate this into a QFP or a QFN

Nirvash
13-02-2013, 22:40
Would it be possible to create a SLAVE circuit to the cRIO to control the small servos or even the motors, to prevent lag. I have an eight core processor that I could use to do all the dirty work...Just note, this would be for next year. not this year...no time

Don't think it would be legal, see quoted rule below, though it would make for a neat project.


R67
Every relay module, servo, and PWM motor controller shall be connected via PWM cable to the Digital Sidecar and be controlled by signals provided from the cRIO via the Digital Sidecar. They shall not be controlled by signals from any other source.

cgmv123
13-02-2013, 23:26
I don't understand why you want to do this. The cRIO has more than enough power to handle whatever you can throw, except maybe intensive vision processing, and the FPGA can go down to the microsecond.

apalrd
13-02-2013, 23:46
This sounds like a terrible idea, even if it were legal (which it is not).

The Propeller is one of the last processors I would want to use as a robot controller. There are far better micros which have far more useful peripherals.

The cRio IO is really quite slow since it's read through the FPGA which itself reads it from the modules over some high-speed bus (unsure exactly what it is), and the layering and OS overhead isn't insignificant, but it's still a 400mhz 32-bit PowerPC with hardware floating point and many megabytes of RAM. The Propeller runs at max 80mhz with an external clock, has 32 IO lines with no analog, no peripherals to speak of other than the 8 cores (Each of which has 512 words of RAM) plus 32K of system memory (RAM and ROM).

For some comparison, some of the MPC5500/5600 processors I deal with could be configured to run the RT control loops of a robot through peripherals and DMA entirely (without any actual processor action or interrupts). That is the processor I would like to use in FRC.

yash101
13-02-2013, 23:50
I was wanting to make it possible for a microcontroller with parallel processing capabilities be getting input, talking to the cRIO, and then send motor output. If possible, I would like the microcontroller to take over while the cRIO is processing an image. This microcontroller costs $8 from manufacturer and $12 from stores and can operate twice as fast as the cRIO. with a clock running at 5MHz and a PLL of 16, 8 cores can give 160 MIPS (160,000,000 instructions per second). That is pretty nice for this. Also, the cRIO needs to continuously interrupt, reducing performance. Sending a Pulse through a PWM means that the cRIO will need to wait for the signal to send before it can do the next thing. This processor can have a core doing it in realtime. The microcontroller has i2c so it can be easily interfaced through the WPILib C++.

yash101
13-02-2013, 23:59
I am working on a schematic for a control board with two MCP3204 chips for ADC 12b. 3v3 and 5v regs, and 256kb EEPROM. I also have programmed this chip in ASM before. Hard, but the performance was just great.

apalrd
14-02-2013, 09:32
That is pretty nice for this. Also, the cRIO needs to continuously interrupt, reducing performance. Sending a Pulse through a PWM means that the cRIO will need to wait for the signal to send before it can do the next thing. This processor can have a core doing it in realtime. The microcontroller has i2c so it can be easily interfaced through the WPILib C++.

Interrupts don't exactly work that way.

There are many ways to do something. The MPC5500/5600 I mentioned earlier has dedicated hardware to time outputs (eMIOS and eTPU) so the processor only has to set them up at init and write a memory mapped register to set the value. The eTPU can even run timing-critical code on it's internal processor, without interaction with the PowerPC. The cRio uses an FPGA to do something similar, neither method requires an interrupt at all.

On a normal processor supporting interrupts, it would be common to generate PWM using a timer interrupt. You could setup the timer to interrupt when you next need to service some IO thing, go on and do other things, and interrupt back when it's time to do something again. All of this assumes the micro dosen't have PWM generation in hardware, most can do it using timers, the propeller has nothing resembling hardware PWM generation.

The purpose of an interrupt on micro programming without a pre-emptive OS is to provide a method to pre-empt the running task to deal with an important event (usually IO or clock related) allowing the running task to go on with it's buisness on a single faster core. There's not very much inherintly inefficient about the interrupt if the code is written well. When you can prioritize interrupts, it's common to run fast code in a low-priority ISR as a basic pre-emptive system.

An embedded microprocessor is frequently surrounded by peripherals which can do a LOT of things in hardware and only signal interrupts when they are needed or wanted. The propeller has none of these, and has to do everything in software. It will spend most of it's time doing these mundane IO tasks which are usually done in hardware, including waiting for events instead of using interrupts, which is exactly how it is designed to work. This means it will spend many clock cycles waiting for timing or spinning until it's ready, where an interrupt driven processor could use those clock cycle to do useful other things and interrupt back when it needs service again.

philso
14-02-2013, 14:27
The processor is a P8X32A, in the form of a DIP-40 chip. I will try to migrate this into a QFP or a QFN

In addition to all the issues that Andrew has raised, I should point out that drawing the schematic is the "easy" part. Laying out a circuit board for a processor like this would require that you have experience designing (properly) multi-layer, high-speed circuit boards with multiple power and ground layers. There are no secrets or black art involved, just years of study. Learning to use the free Altium package only makes you a CAD operator, not a PCB designer. If you do not understand the difference, you are unlikely to design the circuit board properly, leading to "anomalous" operation that will make you tear your hair out. It is also likely that you will have a lot of trouble properly soldering the QFP and QFN packages.

It may be best if you do some research and find out what external processor boards other teams have been using to do their vision processing and buy one of them. It is likely that you will pay much more for just a bare PCB than you will for one of these fully functioning, mass produced processor boards.

EricVanWyk
14-02-2013, 16:50
Excuse my bluntness, but the Propeller doesn't come within spitting distance of the cRIO. The PPC in the cRIO runs at 400MHz and can execute up to 3 instructions per clock - theoretical peak at 1.2 Billion instructions per second. The propellor has 8 cores at 80MHz, but takes at least 4 clock cycles to execute a single instruction - theoretical peak of 160 Million instructions per second. Note: Those are theoretical peaks, neither will sustain that throughput with actual code.

Then look at the quality of the instructions the two processors provide - The propeller doesn't even have hardware support for multiply, the PPC has a full fledged floating point unit and multiple integer units.

Once you add the cRIO's FPGA, it is a "brought a twisty straw and wadded up paper to a battleship fight" scenario.

Adding a propeller to your robot will provide no measurable benefit.

yash101
14-02-2013, 17:24
In addition to all the issues that Andrew has raised, I should point out that drawing the schematic is the "easy" part. Laying out a circuit board for a processor like this would require that you have experience designing (properly) multi-layer, high-speed circuit boards with multiple power and ground layers. There are no secrets or black art involved, just years of study. Learning to use the free Altium package only makes you a CAD operator, not a PCB designer. If you do not understand the difference, you are unlikely to design the circuit board properly, leading to "anomalous" operation that will make you tear your hair out. It is also likely that you will have a lot of trouble properly soldering the QFP and QFN packages.

It may be best if you do some research and find out what external processor boards other teams have been using to do their vision processing and buy one of them. It is likely that you will pay much more for just a bare PCB than you will for one of these fully functioning, mass produced processor boards.
I am in a STEM program and I have teachers that help me with these problems.

yash101
14-02-2013, 17:31
Excuse my bluntness, but the Propeller doesn't come within spitting distance of the cRIO. The PPC in the cRIO runs at 400MHz and can execute up to 3 instructions per clock - theoretical peak at 1.2 Billion instructions per second. The propellor has 8 cores at 80MHz, but takes at least 4 clock cycles to execute a single instruction - theoretical peak of 160 Million instructions per second. Note: Those are theoretical peaks, neither will sustain that throughput with actual code.

Then look at the quality of the instructions the two processors provide - The propeller doesn't even have hardware support for multiply, the PPC has a full fledged floating point unit and multiple integer units.

Once you add the cRIO's FPGA, it is a "brought a twisty straw and wadded up paper to a battleship fight" scenario.

Adding a propeller to your robot will provide no measurable benefit.

I am pretty sure that vxWorks (on the cRIO) uses a lot of the processing power itself, just like how a slow netbook might have a 50% processor usage, running nothing but the operating system.

cgmv123
14-02-2013, 17:47
I am pretty sure that vxWorks (on the cRIO) uses a lot of the processing power itself, just like how a slow netbook might have a 50% processor usage, running nothing but the operating system.

Even if you cripple the cRIO to only a quarter of the specs Eric provided*, it's still no contest. 1/4 of the cRIO's specs still beats the Propeller, and that's without the FPGA, which does a lot of the heavy lifting in FRC. I still don't understand what you expect to gain.

*I'm not an expert, but that sounds unrealistic under normal circumstances or even heavy FRC usage.

yash101
14-02-2013, 18:26
The system I am currently designing is supposed to be modular, kind of like the cRIO. an ADC breakout, PWMPAL Breakout are what I am wanting to create. The modules can easily be swapped, taken out, or be changed in order.

yash101
14-02-2013, 18:29
By the way, What I was asking is if the propeller could do continuous processing, especially when the cRIO is busy. I was thinking about using a Raspberry Pi, but the problem I thought is that it draws lots of power, and you cannot just remove the power plug to shut it down.

ferret_guy
14-02-2013, 18:35
that sounds like a great personal project but in order to match the c-rio you would need something far faster and more advanced. If you really wanted to do this you could use the dio pins and set them to correspond to a single motor controller output

yash101
14-02-2013, 18:38
I am basing it off the arduino, but placing a much better processor instead of an Atmel AVR. Currently I am designing with the P8X32A-D40

cgmv123
14-02-2013, 19:10
Currently I am designing with the P8X32A-D40

Which can't come close to the cRIO. Unless you're trying to do very intensive vision processing/process multiple images simultaneously, the cRIO can handle whatever you throw at it. I still don't know what you're trying to accomplish.

With regards to (this year's*) rules: Coprocessors are allowed, but the cRIO has to control the robot. [R67, R55] Altering PWM pathways is expressly disallowed. [R54, R67] You have to go through the cRIO anyway, so I don't see what you'd gain.

*I (not an expert nor insider) do not anticipate any of the relevant rules changing significantly for (near) future seasons.

yash101
14-02-2013, 22:47
This is to continuously drive the motors. When the cRIO is busy with another task, it cannot output another signal to the Jaguar or Talon. Also, I wanted all sensors to be connected to this. The final output to the cRIO could be possibly: LEFT | RIGHT | BACK | FORW, and the driver input. I really like Parallax products because I find them robust, powerful, efficient and high quality. Parallax has a nice support team, even though they are such a small corporation. They are also quite resistant to some dangerous things like electrostatic discharge. For example, the cRIO could send this chip a command, like RETRIEVE [sensor name], for example, and the chip could give the data. Using a laser range finder, for example, would allow you to get an accurate distance from a point, like the goal in this year's challenge. The cRIO would only have to make the final decisions. Also, I could integrate a CAS into this chip so that when the cRIO needs to calculate large numbers, the coprocessor could do it. When there is only one processor doing a ton of work, the whole system becomes laggy. It is common about how the robot will stop in place while processing an image.

Joe Ross
14-02-2013, 23:15
This is to continuously drive the motors. When the cRIO is busy with another task, it cannot output another signal to the Jaguar or Talon.

As others have told you, this isn't true.

cgmv123
14-02-2013, 23:23
This is to continuously drive the motors. When the cRIO is busy with another task, it cannot output another signal to the Jaguar or Talon. .... It is common about how the robot will stop in place while processing an image.

The FPGA controls the outputs. The CPU does image processing. They can are designed to work in parallel. With proper coding, the cRIO should never be too busy to not set the outputs.

Co-processing complex inputs, like cameras is feasible, legal, and in many cases, recommended.

Bottom line: You are not allowed under current FRC rules to use a separate processor to control or modify the control signal to the motors. It isn't feasible anyway and what you're proposing won't do anything but be very hard to accomplish. The cRIO is an excellent product, get to know it.

apalrd
15-02-2013, 00:47
The point of a real-time pre-emptive operating system is to manage high priority timing critical tasks and low priority less critical tasks on the same CPU.

An operating system can pre-empt the slower or more resource-intensive task to execute a higher priority task, then return to the slower task. In FRC, the slower task could be vision, and the faster task could be everything else. Since it takes at least 100ms to process an image, the faster task could pre-empt the image processing several times for each image processed. The higher priority stuff gets done on time, and the lower priority stuff gets done eventually.

The cRio's PowerPC actually sends data to the FPGA (I'm not entirely sure if it's through mapped memory or something else, but it gets transferred to the FPGA's RAM space) which then deals with the actual sensors. It's almost like your input/output coprocessor except it runs fully parallel at 40mhz. Since an FPGA describes hardware, instead of operating on a vector of instructions to execute it actually arranges logic gates to pipeline the operations all in parallel, so everything happens at once or at a lower clock frequency (e.g. many DIO loops run at only ~150khz to match the max speed of the DIO data).

If things ever stop happening because vision is too demanding, then you need to architect the code to run vision in a lower priority task and VxWorks will schedule it like a lower priority task, pre-empting it when the control code needs to run. This is possible and not very difficult to do, it's quite trivial in LabVIEW.



I also suggest you try to find the time it takes to do a 64-bit double precision floating point divide on the cRio's PowerPC vs the Propeller. Actually, tell me if the Propeller can even do it at all.

The propeller and it's cousin the BASIC stamp are probably my definition of low-power microprocessor. There are many far better chips available which can do a far better job at handling embedded controls.


A far better design direction would be to put vision on a co-processor. There are many solutions that have been tried, I can't recommend any of them personally but some sound reasonably fast.

philso
15-02-2013, 14:09
Devyash

You are attempting to do something that is pretty complicated and difficult. In order for you to be even moderately successful, you will have to climb up a very long and steep learning curve. The first thing you must learn is to realize who around you possess the knowledge that you need. Next, you must learn to listen to those people and to take their advice. It is pretty clear to me that the other posters in this thread have extensive experience in evaluating and selecting microprocessors.


I am in a STEM program and I have teachers that help me with these problems.

If your teachers have extensive experience doing this kind of work, then they can help you. Otherwise, you all have the opportunity to experiment and learn together. I must say that in the last 30 years, I have never seen a fresh (university) graduate who had the required skills to design such a PCB. Maybe one of the other people posting here have but it is probably pretty rare. Regardless, the kind of PCB you need should not be your first PCB design project.


The system I am currently designing is supposed to be modular, kind of like the cRIO. an ADC breakout, PWMPAL Breakout are what I am wanting to create. The modules can easily be swapped, taken out, or be changed in order.

This is a very admirable goal but making it modular is going to make an already difficult task many times more difficult.

yash101
15-02-2013, 18:00
I completely agree. However, another reason why I like this product is because it is cheap. I can go down to a store and get it for $8 plus tax (~$8.08 per chip) that means that we can add more processors if we need and that we dont need to worry too much if we fry a chip. If possible, I would be using a Raspberry Pi with a completely trimmed down linux kernel. However, this processor will take 300mA at a max, with all outputs high (or low) and driving something. I agree that I don't have as much knowledge and experience as a professional, as I am only a high school freshman, but I use AutoCAD Electronics, and I am pretty sure it tries to create the most efficient route as possible. Currently, the biggest problem is that I cant build a PCB with mor than two layers. However, There is something similar, called the HoverFly Pro, that uses a lot of the same technology.

philso
15-02-2013, 23:08
As I have stated previously, this should not be your first design project.

A microprocessor board like what you are contemplating will require 4-6 layers. I have seen examples of such boards done in 2 layers with much less demanding processors than what you are using and they ended in grief. They were ultimately redone in 4 layers.

There are parts of the circuit where it is very unwise to use an autorouter. The real art in PCB layout is in where you place all the components, relative to each other, based on their function. Only then can you get effective and efficient trace routings. CAD programs are only tools for running traces. You still need to know why a trace should be routed in a particular way before running the trace.

Have you priced all the other components that you will need? The bare board will cost you somewhere around $50 from a reputable prototype manufacturer. I am skeptical that you can make a useable board that will take the QFP packages yourself due to the fine pitch of the pins.

Engineering is solving problems by making wise choices. If you want vision processing, you will have to pay a price, one way or another. It may mean paying some money and/or calculating your current consumption and making adjustments in your overall robot design.

yash101
18-02-2013, 22:58
Would it be possible to use the fpga to do all the io processing while the powerpc is doing the image processing and instruct the fpga. after talking to my pltw teacher, he told me that an fpga can do parallel processing continuously.

Jaxom
19-02-2013, 00:09
I am pretty sure that vxWorks (on the cRIO) uses a lot of the processing power itself, just like how a slow netbook might have a 50% processor usage, running nothing but the operating system.

If your OS uses 50% of your CPU you need a new OS. vxWorks isn't that bad. Heck, even Windows isn't that bad.

But to reiterate the answer others have given to your original question: that kind of coprocessing is not legal for FRC; the cRIO has to control your motors. If you're experiencing lag you should spend the time to learn more about your current environment & find out *why* you have lag. It's pretty easy to introduce unwanted lag via programming.

techhelpbb
19-02-2013, 12:10
Not only can someone do this, I already have a Parallax Propeller powering a brushed DC motor control and it does CAN with a Microchip transceiver. That controller is not a FIRST allowed part and can not be used on a FIRST robot without review by FIRST which at this time I have no reason to do.

I also constructed a robot control system with Parallax Propellers at the heart (plural if you like).

There are other people out there with plenty of experience that share your interest though please keep in mind that FIRST does retain the rights to ultimately decide what is on your FIRST approved robot and at this time you'll require far more than a working prototype to achieve what you desire.

So far as I know you can use the Parallax Propeller as a co-processor to the cRIO per the custom circuit rules, but these circuits as others have said, may not operate the motor outputs themselves. So you can't put the motor controllers, hobby servos or even relays on your Parallax Propeller board I/O. You could plug the Parallax Propeller board into the cRIO via the digital side car to...for instance...create a port for an SVGA monitor (though I don't know if having the actual monitor on the robot on the field would be legal you'd have to investigate). I currently see no reason you couldn't interface sensors to the Parallax Propeller such that you could service it with the cRIO. I can see how it might have some value in that sense.

As to the rest....the Parallax Propeller is a very different design philosophy than is common to much of the rest of the microcontroller industry.

It is not realistic to compare the clock speed of the cRIO with the Propeller.

The entire concept behind the Propeller is parallelism. It does not implement interrupts, but it does implement timers and PLL. It also implements shared memory space and common access to that shared memory and I/O using a round-robin fixed timing system.

The Propellor 1 for better for worse is very sparse on peripherals.
This means less idiosyncrasy in the integration.
However that means more glue and extra hardware (which can lead to cost but also to flexibility).

I come from a background of parallel computing using CPUs in mainframes.
To me for some applications the raw parallel nature of the Parallax Propeller makes a heck of a lot of sense when the target system parameters get unspecific.

I also have experience and close ties with Atmel, Microchip, Intel and Motorola. If you know the parameters of your project specifically sometimes it makes the best sense to use a microcontroller / microprocessor that is most closely designed for that purpose as compared to the Propeller which you can probably massage into that purpose.

As far as raw horsepower is concerned...there are plenty of things that a pile of Parallax Propellers can be tweaked to do that the purpose built cRIO would need to be redesigned for.

There is, at least to me, a comfortable middle ground where the Parallax Propeller is a real design option just as the ARM, the Atmel, and the PIC.

As far as the concerns about math, floating point, hardware support....virtually no student I have seen in FIRST is writing code for the cRIO in assembler. The ability to yield pure untainted performance is highly dependent on the quality of the byte interpreter or the compiler optimization. If you really need that kind of raw math performance there are many options including software and hardware coprocessors. One could debate the deciding factors on the impact for a very long time.

Obviously there is a very real limit in which the students will get lost in the large piles of minutia that will ensue.

apalrd
19-02-2013, 13:59
The propeller has basically no peripherals. While that gives you a lot of flexibility in code, there are some things that should stay peripherals.

I work professionally with a MPC5600 series processor, which has a lot of peripherals. The eTPU (Time Processing Unit), eMIOS (Modular Input Output System), and DMA (Direct Memory Access) alone on the chip I am currently working with would take around 192 propeller cogs to get something close in functionality, and the TPUs also additional peripherals to synthesize clocks (e.g. angle clock/angle timestamp) and manage timestamps/clocks that would have to be replicated somehow. This dosen't include SPI, QADC or the actual PowerPC itself. While you could likely move some of the algorithms into the cogs that deal with the IO, you would basically need over 200 cogs to get the low and some mid-level software done, and we haven't even touched comm, OS, or high-level application code.

A good C compiler is basically a requirement for an embedded platform these days, especially with autocoding tools which generate C code from models.

techhelpbb
19-02-2013, 14:11
The propeller has basically no peripherals. While that gives you a lot of flexibility in code, there are some things that should stay peripherals.

I work professionally with a MPC5600 series processor, which has a lot of peripherals. The eTPU (Time Processing Unit), eMIOS (Modular Input Output System), and DMA (Direct Memory Access) alone on the chip I am currently working with would take around 192 propeller cogs to get something close in functionality, and the TPUs also additional peripherals to synthesize clocks (e.g. angle clock/angle timestamp) and manage timestamps/clocks that would have to be replicated somehow. This dosen't include SPI, QADC or the actual PowerPC itself. While you could likely move some of the algorithms into the cogs that deal with the IO, you would basically need over 200 cogs to get the low and some mid-level software done, and we haven't even touched comm, OS, or high-level application code.

A good C compiler is basically a requirement for an embedded platform these days, especially with autocoding tools which generate C code from models.

I can't speak for the cog count you've assigned to these functions but realistically if you really need purpose built peripherals there are many choices to achieve that result. For example I had no trouble at all gluing a Xilinx CoolRunner CPLD or Spartan 3 to the Propeller and I have a rough prototype using the XCore. More importantly I could change the glue to multiply the number of CPLD/FPGA connected to one or many cogs or Propeller chips. (Interestingly the prototype for the Propeller was made in an FPGA).

Realistically speaking if we can compare the Parallax Propeller 1 to the cRIO which includes the FPGA it's only fair to consider the inclusion of similar hardware.

Also there are OS for the Parallax Propeller.

I can't argue that you should back-hand your way to the sort of integrated functions you enjoy on your microcontroller / microprocessor of choice if you don't have some other reason to do it. Surely if those peripherals are your highest priority you'd be foolish to try to round the square peg to fit that hole. Especially if those peripherals are some kind of proprietary IP.

Still I can drive a FIRST robot on a single Parallax Propeller and it would be sort of like the performance of a bunch of the old IFI control systems.

yash101
03-03-2013, 15:58
I agree with that. However, the Propeller, (and BASIC stamp) are really easy to program and work with. I personally like PICs, but programming equipment is expensive and the chips aren't the easiest to work with. Also, most PIC32s aren't available as DIP, so it is hard to prototype without breakouts and surfboards.

Ether
03-03-2013, 16:18
I agree with that.

You agree with what?