My P8X32A-D40 *Solved*
gamemaker90
Posts: 19
Hello all,
My problem is quite frustrating and I need some help. I looked all over google for this problem to no avail.
I recently bought the P8X32A hoping it would be a nice alternative to arduino, but for some reason it doesn't take well to inputs. I made my own Propeller board with a protoboard and a few components as well as a breadboard version. The software I am using is SimpleIDE on the C platform. The computer recognizes the chip and writes to it perfectly, but inputs are not working. I attached a tact switch to p0 and used a pullup resistor as with any microcontroller, but the input only works for a few seconds before going out and sometimes giving a quick flash. Outputs work fine, but inputs don't seem to work. Here's my code:
#include "simpletools.h"
int main() {
while (1) {
int button = input(0);
if (button == 1) {
high(1);
pause(10);
low(1);
pause(10);
} else {
pause(100);
}
}
return (0);
}
Prior to that:
int main() {
while (1) {
int button = input(0);
if (button == 1) {
high(1);
} else
if (button == 0) {
low(1)
}
}
return (0);
}
Please help. I don't know if it's me or just the way it's "supposed" to work, but I would hate to have spent money on a useless piece of junk.
Any help will be greatly appreciated.
My problem is quite frustrating and I need some help. I looked all over google for this problem to no avail.
I recently bought the P8X32A hoping it would be a nice alternative to arduino, but for some reason it doesn't take well to inputs. I made my own Propeller board with a protoboard and a few components as well as a breadboard version. The software I am using is SimpleIDE on the C platform. The computer recognizes the chip and writes to it perfectly, but inputs are not working. I attached a tact switch to p0 and used a pullup resistor as with any microcontroller, but the input only works for a few seconds before going out and sometimes giving a quick flash. Outputs work fine, but inputs don't seem to work. Here's my code:
#include "simpletools.h"
int main() {
while (1) {
int button = input(0);
if (button == 1) {
high(1);
pause(10);
low(1);
pause(10);
} else {
pause(100);
}
}
return (0);
}
Prior to that:
int main() {
while (1) {
int button = input(0);
if (button == 1) {
high(1);
} else
if (button == 0) {
low(1)
}
}
return (0);
}
Please help. I don't know if it's me or just the way it's "supposed" to work, but I would hate to have spent money on a useless piece of junk.
Any help will be greatly appreciated.
Comments
This sounds like more of a hardware issue than a software issue.
Can you please give us a schematic of the circuit for the tact switch? This should include your power connections to the Propeller chip.
Thanks,
Walter
Looks like you might be outputting the result to a led. If so, you need to slow it down.
Most of us use PropTool and spin. It's a simpler language. Many objects like serial are written in assembler and run in their own cogs (CPU cores).
How about you post a pic of your setup in case there is a problem with your board. Make sure you have all power and ground pins connected, BoE tied to ground, and have decoupling caps on the power pins. Of course you are supplying 3.3V DC regulated, and not 5V like the arduino processors mostly use.
BTW once you understand the prop you will never go back to the AVR/Arduino !
The biggest thing though is you will not find a more helpful or knowledgeable community anywhere.
Welcome to the community.
Try setting the pauses in the "if" loop to a larger value (at least 100). When trying something new I usually will use pause(500) after the high to make sure I don't miss it.
What are you using as a power source?
Hope this helps.
Tom
It sounds like you have your button circuit wired in reverse.
If High is to be On then it's an Active-High button so it should have a PULL-DOWN resistor.
http://learn.parallax.com/tutorials/language/propeller-c/propeller-c-simple-circuits/check-pushbuttons
Pull-Ups are if you want the button to be Active-Low, or pressing the button returns a Low or 0 value.
1:
This works on arduino and like I said and temporarily for the propeller chip
2: I tried compiling some of the sample code and got the same results. Be it c or spin it does the same thing, and yes 3.3v is the only power on the thing. I skipped out on using any other voltage regulator than the LD33V voltage regulator from a 9v battery (outputs 6v though, getting kinda old). Also I read the datasheet cover to cover pretty much. I know about the cogs. BoE is tied to gnd and I do not have any caps on the circuit. (I just added one from vdd to gnd and it went out even sooner).
3: A 5Mhz crystal oscillator it even says 5.000 on the thing itself. I made sure to get all the right parts minus the EEPROM which the datasheet says is optional (of course it says the crystal is too but you can't believe everything, lol).
4: Yes I agree. Getting this was in hopes of getting away from arduino anyway. I really do hope this works, and thanks this is the only other forum I've been a member on besides the Game Maker Community.
5: My powe source as stated above is a 3.3v voltage regulator. As I reassebled everything to test it however I noticed that it may be the outputs and not the inputs at all. I ran the demo "Blink Light.c" and the LED blinked about 70 times then stopped. Depending on the speed the LED flashes though it has the tendency to go out sooner or later...
6: Sorry for the confusion I think I meant pull down. It was 2:45 in the morning when I posted this (Yeah I was up practically all night trying to get BOTH my P8X32A's working, and yes I have 2 they both are giving me the same problem though). As far as the link goes, every time I searched this up on google that page came up. Me and that page don't get along so well...
Any way here's a picture of my current setup where the LED flashes a few (50-100) times before going out:
The breadboard is the target and behind it is the protoboard version. Both boards are functioning the same so I know it's not my solder joints.
It might be a good idea to insert a series resistor between the point you've got marked as P0, and the actual Propeller P0.
This would protect the Propeller in case you have the P0 set to output low in code, then press the button to short that to 3.3V.
The resistor values are not needing to be precise for a simple switch, but for example if you used 10K series resistor and 100K pulldown, that would work for most cases and be pretty robust for you.
Also do you know of any good tutorial sources for spin?
Download the Spin Tool:
https://www.parallax.com/downloads/propeller-tool-software-windows
Open the Tool and go to Help, and open the Propeller Education Kit (pdf). It has the basic for getting a Propeller going.
EDIT:
One other thing: the chip itself doesn't hold the code after I disconnect power. My guess is that's what the EEPROM is for. Correct?
This is good advice. If you follow the pdf you'll probably be able to blink LEDs in fancy patterns before the day is out!
Yes, that is what the EEPROM is used for. Unlike the Arduino boards and most modern microcontrollers, the Propeller does not have any non-volatile memory.
Even though you got your Propeller working with C, I'd still definitely recommend you give Spin a try at some point. Many will disagree, but I and many others find it to be much simpler and much better suited to the Prop.
Probably bad power. You should have a 10uF tantalum on the output of the regulator. You will require at least a 100nF (0.1uF) at the prop's power/ground pins. I know it will work without if your power regulator is close by, but it can be unreliable!!!
It's true that you can run without an xtal. Use the internal rc option. It will blink your LED and it will download code. But it will not work reliably serially to your PC because of the process variation in the RC oscillator. And as you found, you don't need the eeprom but it will not save and reboot your code.
In one of the directories of PropTool there are examples/tutorials (about 10 IIRC) that goes through spin and starting multiple cogs. Doesn't take long and its easy to understand. There is also a cheat sheet - 2 pages each for spin and pasm (assembler). The base instructions for pasm are quite simple compared to any of the other micros around.
Good that you have it working but just so you know C has only been on the Propeller for 2 years so not everything is available in code.
Spin is the Propeller's native language and to many is not as cryptic or quirky as C.
The best Spin tutorial is the Propeller Education Kit text and you can also download the code from here.
https://www.parallax.com/product/32305
You can use a breadboard but Parallax makes some very great boards such as the new Propeller Activity Board WX that's used for Propeller C.
https://www.parallax.com/product/32912
http://learn.parallax.com/tutorials/propeller-c
Most of the code for video I still in Spin and if you want to play games then the Hydra is what you want.
https://www.parallax.com/downloads/hydra-manual
Welcome to the Parallax forum and if you have any more questions then feel free to ask.
Spin is precisely suited to the Prop, and makes perfect sense once you spend an hour studying it. As much effort as the "C" guys have put into splicing it to the prop, spin just plain ol' works better. In my opinion. tc
Edit: Mostly because prop 1 doesn't have enough RAM, either hub or cog. P'raps prop 2 will be better suited to C. Ended it