Maker Pro
Maker Pro

MOTOR SPEED CONTROL

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
Thanks I will get the parts and try the circuit and post the results.
But I don’t get it how do I program it? Can I just run some cables from the serial port of my computer to the breadboard and connect it to the picaxe pins? Or I need to buy one of those boards that connect with my computer? Can you tell me the code with which to program it? Sorry for the dumb questions.

Did you read the Picaxe information? The Picaxe family does not require a hardware programmer/compiler. There's a wealth of information on the Picaxe web page. Download the Programmer/Compiler software and the manuals, they're all free. You can be running basic code in the simulator by this time tomorrow.

http://www.picaxe.com/What-Is-PICAXE

You can program a Picaxe with a Serial cable and a few passive components but most PCs no longer have RS232 ports. Picaxe sells a USB/Serial cable for this. Here's a Starter kit.

http://www.picaxe.com/Getting-Started/Purchasing-a-Starter-Kit/

For direct RS232 connection see page 8 of the "Getting Started" manual.

http://www.picaxe.com/docs/picaxe_manual1.pdf
 
Last edited:

arg733

Dec 14, 2010
89
Joined
Dec 14, 2010
Messages
89
Hi finally the picaxe arrived from UK and I am making a pcb for it. Meanwhile a have been reading the 3 PDFs but I just can’t figure out what commands to use. From what I understand, the pot to control the rpm is not so accurate, as I have some function generators it is very easy to give a set freq and to change it very accurately to pin2.
So the program should be something like this:
Count pin 2 store . Count pin 4 store.
If pin 2 freq > pin 4 freq then decrease the pwm freq on pin 5. If pin 4 freq decreases even more decrease the pwm freq.
If pin 2 freq < pin 4 freq then increase the pwm freq. If pin 4 freq increases even more increase the pwm freq.
Thank you.
 
Last edited:

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
Does this mean that you haven't been practicing and familiarizing yourself with the simulator while you've been waiting for the hardware?
 

arg733

Dec 14, 2010
89
Joined
Dec 14, 2010
Messages
89
I have been practicing with the “Logicator” and the “Picaxe programming editor” using flowcharts (when I try to use basic my head blows up I have never done any sort of programming) but I realized that flowchart does not cover all the commands.
I have been able to make a program with the logicator but it isn’t really what I need as it has only 2 states. I need it to increase the frequency and duty cycle linearly from the lowest specified value to the highest just as a potentiometer. Oh and I give steady pulses from a pwm to pin 2 instead of using a pot. Below is the “flowchart”
 

Attachments

  • 1.jpg
    1.jpg
    38.9 KB · Views: 139

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
Loose the Logicator. Play with the example code (pertaining to each command) by copying it from the pdf and pasting it into the code editor. Then click RUN / Simulate.

Chris
 

arg733

Dec 14, 2010
89
Joined
Dec 14, 2010
Messages
89
Yeah i got that but i cant find any command in the pdf to tell it to vary from 5khz 80% to 20khz 20%...
could you plz give me some clues?
should i ask for help on the "Microcontrollers and Programming" section of the forum as it is more a software rather than hardware problem at this point? (thanks to you of course, i have never head of the picaxe before.)
Thank you.
 

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
IMHO you're still putting the cart before the horse. An electronics nube doesn't make his first project a 1GHz Spectrum Analyzer. Likewise, a novice programmer doesn't attempt to write his own OS as his first project. But if you insist, look for the following commands found in Picaxe_Manual2.pdf titled "Basic Commands".

pwm (page 163)
pwmduty (page 164)
pwmout (page 165)


Picaxe Forum:
http://www.picaxeforum.co.uk/forumdisplay.php?2-Active-PICAXE-Forum
 

arg733

Dec 14, 2010
89
Joined
Dec 14, 2010
Messages
89
pwmout was the first command i saw when i first opened the pdf but if i use it as the pdf suggests it will basically do the same with the flowchart (it will have only 2 states). how can i tell it to increase and decrease the frequency linearly between the 2 specified values and not to jump form one to the other??? for example when the rpms are 5500 it should give 12khz 40%.. when the rpms are 6000 15khz 30% and so on.. that is what i have been searching for desperately. I start a so difficult project as my first one in programming as i have no choice. i need it very much. i was sure that i will find something on ebay or somewere else before i asked for help on this forum. i would never had bothered trying to program something my self until i am a little older and know how to make a simple computer program.
 
Last edited:

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
pwmout was the first command i saw when i first opened the pdf but if i use it as the pdf suggests it will basically do the same with the flowchart (it will have only 2 states). how can i tell it to increase and decrease the frequency linearly between the 2 specified values and not to jump form one to the other??? .....

Arg733, may I ask how old you are? The Picaxe and it's language is designed for young students. Your statement here leads me to believe that you're not grasping the basic concept of programming. The fact that the example given shows only two PWM values doesn't mean you're limited to the example.

Here are the most important 'Statements' or 'Commands' regardless of programming language. Languages like Picaxe Basic lists them all as commands.

If
Then
Else
ElseIf
=


The next most important commands are as follows..

And
Or
Not
Is
<
>
<>

These 12 commands put a world of power in your fingertips!

To summarize,.. I told you before that programming should be learned from the ground up, not from the top down, as you're trying to do. You seem to be on a time limit. Is this a class project of sorts?
 
Last edited:

arg733

Dec 14, 2010
89
Joined
Dec 14, 2010
Messages
89
I am 16.
This is not a school project, here in Greece they don't teach things like programming instead they teach some other subjects that from my point of view are completely useless.
What i cant seem to achieve is:
If (b0 - b1) > 1
then pwmout + 20hz

as you guessed i am in a hurry as school will start in a couple of days and i wont have enough time anymore to make the pcb , program the picaxe and test my newly built circuit.
Thank you.

Ok someone on the picaxe forum just gave me the code. I will need to try it and update tomorrow.
 
Last edited:

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
I was truly hoping that you'd work it out yourself. You're robbing yourself of the satisfaction of self accomplishment.

Chris
 

arg733

Dec 14, 2010
89
Joined
Dec 14, 2010
Messages
89
yep me too if i had few more months i would had tried to do it my self :)
i will post the results and commands if it succeeds for others with the same problem to find
Thank you for your help i would had never found the solution without you as i had never heard of the picaxe before and you provided the circuit.
 
Last edited:

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
Good luck to you. uC's will open a new and exciting world to you.

Chris
 

arg733

Dec 14, 2010
89
Joined
Dec 14, 2010
Messages
89
Good luck to you. uC's will open a new and exciting world to you.

Chris

Hi, after practicing with their code (which didn't work by the way) I finally understood how it works (it wasn't as hard as i believed it to be) and came up with my own code:

I have no scope so I cant know if the duty works but the frequency sure is. I tried it with 2 function generators (instead of using a pot to control the rpm i will be using the function generator as it is more easy to code) and a frequency counter.

I will test it on the motor and post the results in a couple of days.


---------------------------------------------------------------------------------------------------------------

Code:
Symbol speed = w0
Symbol demand = w1
Symbol Frequency = w2
Symbol Duty = w3

main:
count 4, 100, speed
count 3, 100, demand
if speed < demand then
frequency = frequency + 5
else frequency = frequency - 5
endif
let frequency = frequency min 54 max 200
pwmout 2, frequency, 300
pause 10
goto main


'min 54 sets the highest frequency value and max 200 the lowest.
'to lower the frequency you need to increase the max value and 
'to increase the frequency you need to decrease the min value.


'You can adjust the speed with which the frequency changes by
'adjusting the frequency +-5 and the pause length.
 

Attachments

  • mZOZ4TLWQWLxpD3XV5qOsFQ.jpg
    mZOZ4TLWQWLxpD3XV5qOsFQ.jpg
    9.5 KB · Views: 79
Last edited:

wingnut

Aug 9, 2012
255
Joined
Aug 9, 2012
Messages
255
I have no scope so I cant know if the duty works but the frequency sure is.

Why not install Winscope on your pc and turn that into a scope with a few resistors and a jack into the microphone socket? There is also a program called Frequency Counter which uses the same interface and does what its name suggests.
 
Last edited:

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
Arg, when you post code copy it from your Picaxe editor and paste it between Code Tags. Doing so will keep it formatted.;)

Chris
 

arg733

Dec 14, 2010
89
Joined
Dec 14, 2010
Messages
89
Why not install Winscope on your pc and turn that into a scope with a few resistors and a jack into the microphone socket? There is also a program called Frequency Counter which uses the same interface and does what its name suggests.

Winscope ? never heard of it I will gather information and try it.
Ok found it.
I must be very careful to use voltage dividers so to not burn my poor little computer :) (voltage regulators will most certainly alter the waveform won't they?)
 
Last edited:

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
Winscope has a bandwidth of about 20Hz to 20KHz. A 20KHz square wave will look more like a sine wave. Be aware that the vertical scale is not calibrated. It can't see a DC level either.

As PC based scopes go the USB versions are far Superior but aren't free.

Chris
 

arg733

Dec 14, 2010
89
Joined
Dec 14, 2010
Messages
89
Winscope has a bandwidth of about 20Hz to 20KHz. A 20KHz square wave will look more like a sine wave. Be aware that the vertical scale is not calibrated. It can't see a DC level either.

As PC based scopes go the USB versions are far Superior but aren't free.

Chris

yeah usb based are 150-300$ and a stand alone scope is 200-300 so almost same money and much better.
 
Top