Flip and propellerC language; RESOLVED
bbrien
Posts: 561
I am lost, I tried to use a arduino and wrote a program with the help of some people on the forum. For some reason I am unable to get the PWM to a low enough value. I believe vthat the problem has to do with the operating frequency which is 16 mega Hz.I am now using the Flip board. I would like to get some examplkes using four digital inputs and four digital outputs,two for the enable pins and two dirrection pins of a UDN2993 driver chip. Arduino program is about 3700 bytes in size.
Comments
https://www.parallax.com/sites/default/files/downloads/122-32305-PE-Kit-Labs-Fundamentals-Text-v1.2.pdf
For C:
http://learn.parallax.com/tutorials/series/flip-try-it-kit-c-tutorial-series
Blockly also produces C code:
http://learn.parallax.com/tutorials/language/blocklyprop
What is your project?
Note: This is an object (library) -- not an application. You will attach this to your application code.
My project is a telescope mount(Meade LX50) circa'2010'. It has two "DC clock motors" hooked to gearboxes turning the shafts. The azimuth axis has to rotate at a speed of approximately 1.5ms with a period of about28.5ms or a freq, of 50Hz.
For the methodology (which is really quite simple), there are a bunch of good vids on Youtube that cover the topic quite well.
Gave it a try but when I put in the # from my last post I got an invalid number message. What I am trying to do is set my I/O register.
int mask = 0x3fffffff; // creates an integer variable mask and initialize it as a bit mask with 1's in each place except for bit 30 and 31
DIRA = mask // set direction register to the bit mask for outputs.
"0b 0001 1111 1000 0000 0000 0000 0000 0000 "
Hex 1 F 8 0 0 0 0 0
Hope it lines up when posted.
Edit - Wishful thinking on having it line up, but I hope it gets the idea across.
Edit: confirmed. When I run your number (without the leading 0b) the calculator returns 1F800000.
Thanks for catching that omission. Another case of "everyone knows thatitis"
I tried out the numbers and the board loads successfully but I still have to test the input and the outputs. Now all I need to do is find out how to read four switched input pins with prop C.
Pin1= output1+output3
pin2= output2+output4
pin3= output2+output4
pin4= output1+output3
Do I need to check them one after another or together at the same time. And if so how would I code This.
"int button = input[3..5]; error
"int button = input(3);
int button = input(4); also error
I cant find any examples in prop C.
If you're wanting to mimic this Spin code: ...you can add this function to your program: This will read a contiguous group of pins defined by msb and lsb. Again, Spin is my normal language, so one of the C experts may have a better solution.
From the Propeller C reference simpletools.h
Group I/O
What you do with that information is up to you. You will need a mask for each pin to test its state.
If P3 and P4 were high, and P5 and P6 low, the value of pinStates would be 0b1100. Now that you have those states captured, you can act on them. I -- and I suspect others -- are still trying to suss out what you want to do with the input states.
Several Errors "expected declaration specifiers or "..." before numeric constant(2)
I don't understand and how do I fix. Thank You
to make the board run at 5MHz . How do I declare the variables without "#define. If you can show me a better way, I am all eyes.
I'm assuming you're using SimpleIDE, so you would set clkfreq and clkmode by defining a new board type. You need to locate where boards.txt is on your computer, and edit it to add a new board type entry. You then need to create a *.cfg file containing the board information.
On my Windows system, the board type files are located in the directory C:\Program Files (x86)\SimpleIDE\propeller-gcc\propeller-load. I added a custom.cfg entry to my boards.txt file, and I made a custom.cfg file based on the hub.cfg file. My files are in the attached zip file.
If you want to try changing the board types, type "admin" in the search field on the task bar, and then click on "Run as administrator". This will allow you to change the files in the propeller-load directory.
_CLKMODE = XTAL1;
_builtin_propeller_clkset( ); looks unknown to me, Do I put "xtal1" in the mode or what and where do I put all of This , Before or after the"int main()",
The statement #define clkset ( mode, frequency ) is a macro. You only have to enter the value for mode and frequency into the parentheses.
The stuff under "value" is just what that macro does.
So you need mode & frequency.
First:
clkfreq = the xtal frequency * the PLL value (1, 2, 4, 8, or 16)
So if you want a frequency of 5MHz you need a xtal whose value is 5MHz / (one of the PLL values).
So if your xtal is a 5MHZ crystal, you would use PLL1X.
Then Clock mode = XTAL1 + PLL1X = 0b01101011 = 107
from page 69 of the propeller manual or page 14 of the propeller data sheet.
The frequency is 5000000.
Try those.
Note: the SimpleIDE Libraries are documented here:
https://cdn.rawgit.com/parallaxinc/propsideworkspace/master/Learn/Simple%20Libraries%20Index.html
The propeller manual is here:
https://parallax.com/sites/default/files/downloads/P8X32A-Web-PropellerManual-v1.2.pdf