C code
Hello all.
There are a couple of things I want to make and can't really get them right.
I start with how to measure the voltage from a capacitor using C. I tried the RCTIME yet it says that is not correct.
I have wired it with the pin and vin going to the positive and the ground at negative. Any ideas for the code or am I dong the wiring correctly?
I have also a RGB sensor (TCS34725) from adafruit. It is supposed to be a colour sensor yet I have no idea how to wire it and what to write. If anyone has a similar product and can guide me I am thankful.
Got as well a TAOS (TCS230) colour sensor. Any ideas on that one as well how to wire it and what to write?
Finally xbees. I have 2 xbees, haven't programmed them just out of the box. I am using the boards shared below in order to connect to the breadboard.
Nevertheless the 2nd doesn't reply at all and the xbee is getting hot! The USB one is blinking a led (ASSOC) and the xbee is getting hot as well. Could someone share a wiring picture? I had a xbee series but someone told me that they need MCU (I never understood anyway) and suggested that I go for the series1. I just want to test that they can receive and transmit, wiring them on a single propeller and using different cogs to control each one.
Thank you very much for your time and help.
P.S. For parallax staff, will there be a book with examples, like the one for basic, which by the way was amazing?
links:
https://www.adafruit.com/products/1334
https://www.parallax.com/product/28302
http://www.adafruit.com/product/128 or this exactly: https://abra-electronics.com/images/detailed/81/WRL-08665__86860.jpg?t=1414791140
http://www.droids.it/cmsvb4/content.php?152-990-002-XBee-USB-Board
http://www.droids.it/cmsvb4/content.php?143-990-001-XBee-Simple-Board
There are a couple of things I want to make and can't really get them right.
I start with how to measure the voltage from a capacitor using C. I tried the RCTIME yet it says that is not correct.
I have wired it with the pin and vin going to the positive and the ground at negative. Any ideas for the code or am I dong the wiring correctly?
I have also a RGB sensor (TCS34725) from adafruit. It is supposed to be a colour sensor yet I have no idea how to wire it and what to write. If anyone has a similar product and can guide me I am thankful.
Got as well a TAOS (TCS230) colour sensor. Any ideas on that one as well how to wire it and what to write?
Finally xbees. I have 2 xbees, haven't programmed them just out of the box. I am using the boards shared below in order to connect to the breadboard.
Nevertheless the 2nd doesn't reply at all and the xbee is getting hot! The USB one is blinking a led (ASSOC) and the xbee is getting hot as well. Could someone share a wiring picture? I had a xbee series but someone told me that they need MCU (I never understood anyway) and suggested that I go for the series1. I just want to test that they can receive and transmit, wiring them on a single propeller and using different cogs to control each one.
Thank you very much for your time and help.
P.S. For parallax staff, will there be a book with examples, like the one for basic, which by the way was amazing?
links:
https://www.adafruit.com/products/1334
https://www.parallax.com/product/28302
http://www.adafruit.com/product/128 or this exactly: https://abra-electronics.com/images/detailed/81/WRL-08665__86860.jpg?t=1414791140
http://www.droids.it/cmsvb4/content.php?152-990-002-XBee-USB-Board
http://www.droids.it/cmsvb4/content.php?143-990-001-XBee-Simple-Board
Comments
Could a series1 and series 2 also communicate?
Series 1 can not talk to Series 2.
Here's a good video to watch:
https://www.youtube.com/watch?t=109&v=RYQpZWij2-M
The "Getting Started with xBee RF Modules" text can be downloaded here: https://parallax.com/downloads/getting-started-xbee-rf-modules-text
There's a good detailed discussion of the use of RCTIME here: emesystems.com/BS2rct.htm
Taos examples are very complicated. It is either as steps or one cannot understand anything, especially with no background for this.
There must be some videos with wiring etc and C code from the people that know these. This is the drawbacks compared to arduino.
Using the BS2 book was great because it had everything there.
To explore the full Learn website, start at to http://learn.parallax.com, otherwise follow some of the examples I have listed below.
XBee communication in C-language
General C Programming
What's a Multicore Microcontroller? is currently in development. It will be the C equivalent of the Basic Stamp "What's a Microcontroller?" text, but it is not yet finished. To take a look at what Chapters 1-6 look like, download a free copy here: https://www.parallax.com/downloads/whats-multicore-microcontroller-text. Some of its information may be helpful to you and your current project.
Here is an example that measures RC-Time using C.
http://learn.parallax.com/propeller-c-simple-circuits/sense-light
Based on that Abra photo you have an OEM version of a Series 1 XBee.
Here is the equivalent Parallax part:
https://www.parallax.com/product/32405
These are the Parallax versions of your Droids' XBee Adapter Boards.
https://www.parallax.com/product/32400
https://www.parallax.com/product/32401
Here is an example XBee setup where a remote XBee will echo back whatever is sent to it.
Note the "loop-back" configuration of the remote setting and that these use Parallax adapters so your Droids' boards may have the same connections in different places.
Unfortunately this example uses Spin, not C, but the Arduino code may make sense to you.
http://learn.parallax.com/KickStart/32440
I have tried for the rctime to copy the bs2 schematic.
The code goes like this:
#include "simpletools.h"
int main()
{
while(1)
{
high(5);
pause(100);
int t = rc_time(5, 1);
print("t = %d\n", t);
pause(1000);
}
}
Nevertheless I get an indication of up to 1.56volts from there and upwards the number from rctime is the same.
I have a resistor (220Ω) connected to the positive of a capacitor and the same resistor from the negative to the ground. Saw it from this one: http://www.parallax.com/go/PBASICHelp/Content/LanguageTopics/Commands/RCTIME.htm
what can I do in order to get a number throughout the spectrum of the voltage, 3,3 and 5v.
I have a propeller education kit https://www.parallax.com/product/32305.
I am running low on pins and I want to expand using the MCP23008 or the MCP23017.
I read in the learn section about the I2C protocol yet I am not totally sure if that answers my question.
I want to control some leds or servos using the MCPs. Use 3 pins to control many more. I guess it is
the basis depending on the combonation of pins high and low status it responds differently, or not?
Do I need to write something in the main program or its just wire and go?
If you just want to turn LEDs on and off, it's pretty simple. Servos are more complicated because of the accurate timing needed ... I don't recommend that.
If you want to control a lot of servos (and LEDs) you might consider using a second Propeller with a high speed serial link connecting the two. Parallax's Propeller Servo Controller is a good starting point (see here). The code is available and could be downloaded into a Propeller-Mini or PropStick for a physically small solution.
I just want to power leds for start. In the beginning on the code (C) do I need to state anything. I show an example from BS2 that had some CONs. If I just connect the three pins to the MCP and try out the high-low will it do anything? If it doesnt work out I will just use a second prop with xbee. One more question how can I connect with cable a prop and a bs2? How will the code to send and receive will be like? I was hoping to control with one pin using different pulses.
There are several objects in the Propeller Object Exchange for I2C. Look at them. Some of them may have code for the MCP23008 or MCP23017.
As I mentioned in the previous post, you have to initialize the MCP23008 and MCP23017's registers depending on how you want to use them. The datasheets show what the various registers and specific bits do.
You can connect a Prop and a BS2. Because the BS2 uses 5V logic signals and the Prop uses 3.3V logic signals, you have to use a 4.7K or higher resistor between the connected I/O pins. If you don't, you'll burn out part of the Prop's I/O pin circuitry. You could use one I/O pin on each controller, but I'd recommend using serial I/O rather than different pulses. You can pass more information that way.
I connect Pin 10 from prop to Pin 0 in BS2 using a resistor and connect their grounds as well. Then I give a high(10) command from prop and an IF IN0= 1 then ... Is it correct?
I do the inverse from the bs2 to prop.
Regarding the BS2 RCTIME command help, the 220 Ohm resistor is only there to protect the I/O pin should something not work properly. Notice there is also a C and an R in that diagram; Those are the actual Capacitor and Resistor that you will be measuring.
Remember though that the BS2 uses 5V while the Propeller uses 3.3V so the trigger voltages will be different. Also the Propeller has a much faster clock rate than the BS2 so the Propeller has a much higher Resolution, or the smallest change that it can detect.
I don't understand what you mean by wanting a value from the 3.3V to 5V range.
Usually C is fixed and R will vary so the RCTIME value will change as R changes.
In that Sense Light example I linked above you can see a 0.01 uF capacitor.
In the Try This near the bottom of the page, it shows that changing the capacitor to one that is 10X larger, 0.1 uF, will make the measurements take 10X longer.
Depending on what you are measuring you may need to change the capacitor value so the RC_Time values are in the range that you want.
What exactly are you trying to do?
The Propeller Education Kit (PEK) is great but everything is done in Spin and you want to use C.
PBASIC which the BS2 uses and Spin are very similar. I started with the BS2 and learned Spin mainly from the Propeller Education Text.
C is only a recent addition to the Propeller so most of the older code and examples hasn't been translated yet.
Stephanie mentioned the new What's a Multicore Microcontroller text that is the Propeller C equivalent of the What's a Microcontroller text for the BS2.
The new text isn't finished yet but it may have many of the things that you want to do.
Here is the code for the text link that she provided.
https://www.parallax.com/downloads/whats-multicore-microcontroller-code-examples
The BS2 is slow and can only do one thing at a time while the Propeller is a lot faster and has 8 independent Cogs (aka cores).
This activity shows you how to use I2C on a Propeller in C to access an EEPROM.
http://learn.parallax.com/propeller-c-simple-protocols/diy-i2c
These 2 examples have the base code you would need for doing I2C on a BS2.
http://learn.parallax.com/KickStart/29133
http://learn.parallax.com/KickStart/27911
Ask Mike said there are also Nuts and Volts articles on BS2 I2C. The KickStart code I linked in based on the code from these articles.
The BS2 can also do Serial using the SERIN and SEROUT commands.
The BASIC Stamp Manual has information on all the commands and how to use them.
https://www.parallax.com/downloads/basic-stamp-manual
Just be sure that you have the correct baud rate and mode selected and remember the BS2 can only do one thing at a time so if the Propeller sends serial.
What are you trying to do with P0 of the BS2, P10 of the Propeller, and the grounds?
Also what are you doing with the Propeller that has used all of your I/O pins?
I actually building a hudraulic arm, and due to the h brisdges I have used almost all my pins. I have still 8 left but need to plug in a led panel to show which point is operating. I wanted to avoid the solution of buying a new propeller and using xbees although I have them from the bs2.
I am very sorry if you dont understand what I am trying to say, truth is I started with BS2 and spin was too complicated for me, so I turned to C.
I was hoping that there was going to be a sample code for all sensors and parts in C. Anyway if I find a solution I will let you know.
Cheers!
The C is not understanding the serial and thus I am having troubles. I want the propeller to send the information to the bs2 and the bs2 to show it on the LCD screen. I will use highs and lows and loops in order to translate this data into what I need.
If you have any idea that would be great. Thank you!