serial comm with propeller
realolman1
Posts: 55
I would like to communicate with the propeller using serial comms. It seems like everything I can find on the subject immediately jumps way past my skill set.
This is what I would like to do to try to get a hold on the subject:
how about the propeller adds two numbers together and then sends the results to the serial terminal or something very simple like that, so the use of the full duplex program doesn't get lost in pages of programming ?
If I can just see how a simple task would be accomplished, I think I could expand upon it, but I never am able to find anything that is on a level this simple.
I have the fullduplexSerial driver installed... could someone show me an extremely simple program that uses it to send and/or receive between the Serial terminal and the propeller, using nothing but the serial cable and possibly some resistors and jumpers .... maybe the propeller could send which input is high or low.... that'd be great
thank you
and it would appear that I probably put this in the wrong forum category ... sorry
This is what I would like to do to try to get a hold on the subject:
how about the propeller adds two numbers together and then sends the results to the serial terminal or something very simple like that, so the use of the full duplex program doesn't get lost in pages of programming ?
If I can just see how a simple task would be accomplished, I think I could expand upon it, but I never am able to find anything that is on a level this simple.
I have the fullduplexSerial driver installed... could someone show me an extremely simple program that uses it to send and/or receive between the Serial terminal and the propeller, using nothing but the serial cable and possibly some resistors and jumpers .... maybe the propeller could send which input is high or low.... that'd be great
thank you
and it would appear that I probably put this in the wrong forum category ... sorry
Comments
Here's a program which requests two numbers and provides a total.
You'll want to make sure to familiarize yourself with ASCII encoding of characters.
I mixed local and global variables for the heck of it.
Here's the output:
There are many different ways this sort of program could be written.
Your program works like a charm.... now I'll have to study it and see if I can understand how it works.
Thank you very much
I don't know if you're familiar with the carriage return character but this character has the numeric value 13. The value 11 is used by the Parallax Serial Terminal.exe program to clear the end of a line. I the combination of 11 and 13 to clear the end of a line and then move to the next line down.
Clearing the end of the line becomes a lot more important when you have text which stays in one location on the screen.
I used the constant "QUOTE" in place of the double quote character. You can see this character has the numeric value 34. You can see the numeric value of many characters by selecting "Help"\"View Character Chart".
Wikipedia has a good article on ASCII characters. If you're not familiar with ASCII characters, I suggest you look at the Wikipedia article.
What I would like to eventually do is communicate between the propeller and a BASIC program ... whatever is the current free version...if the current version will do serial comms
I have tried that in the past with very little success.
The best success I ever had was using a LAB JACK, but I would like to try some things that don't require the computer to be involved continuously.
I always was hooked on this kind of thing but never had the time. I retired a little over a year ago and now I have more time.
Thank you for your help, and please don't hesitate to provide more
I know that is small potatoes for many of you, but it's a giant leap from where I was this morning.
thank you
Believe it or not, that's a fairly sophisticated task. I do this kind of thing a lot (well, not adding numbers, but processing commands). I created a parser object that gets used in a lot of personal and professional projects. It allows me to accept commands from a serial stream, or -- as in a few designs -- I can read a string from a file and send it to the parser for processing. This allows my projects to have command files that are simple text.
I've attached a demo in case you want to give it a try.
Maybe eventually I will get to where you are with "parsers" and "serial streams", but now I am clueless about a parser. I looked it up and became even more clueless.
I modified some of what Duane Degn posted to end up with this:
In a Visual basic program I put a few buttons that "Write" either an "s", "q", or an "x"
the propeller toggles LEDs according to the character received.
It seems to me that something like this could be modified and expanded to be much more useful
I get lost pretty much immediately in many of the programs posted by people who know a lot more that I do
I don't want to be an ingrate... I just don't know what to do with the files you posted... I looked at them and they are way over my head.
thank you
I have a list of tutorials in my "index" (it's not alphabetized so I'm not sure why I call is an index). The third post in the thread has the tutorial links.
I personally learned Spin from the original Propeller Manual (v1.0).
If I were starting again, I'd probably use Parallax's Learn site and the Propeller Education Kit (PEK) materials to learn to program the Propeller.
JonnyMac publishes articles titled "Spin Zone" in Nuts and Volts. I've learned a lot from these articles. Jon's articles particular helped me understand programming using assembly (PASM). (There's a link to Jon's articles in my index.)
I also learned a lot from reading these forums. I think you'll be hard pressed to find a friendlier electronic forum than this one here at Parallax.
I started learning about microcontrollers about eight years ago. I had always thought I'd like to be able to program microcontrollers but I had severely underestimated how fun this stuff can be. Here's a playlist I put together showing some of the fun I've had with the Propeller.
Keep experimenting, keep learning Spin, and keep looking at programs written by others. As your skills improve things will begin to make sense. It works that way for all of us.
Run the program (jm_parser_demo) and open a terminal (I use PST, but any serial connection will work). The syntax for the included commands are detailed in the code. The easy ones that you can try with an LED are HIGH, LOW, and TOGGLE.
A parser breaks apart some form of string input so that the constituent parts can be dealt with. For example, if you run my program on the PAB, open a terminal, and the entering HIGH 26 followed by [Enter], the LED will light. The parser code takes all the characters until you press Enter, and then breaks them up (using spaces or other non-characters as separators). It then looks into its known list of commands. LOW is in that list. In the code that handles LOW, the second parameter needs to be a number between 0 and 27 (I protect the I2C and serial pins with my commands).
Again, I didn't knock out that code overnight, you won't learn it overnight, either (especially being new).
I don't consider you ungrateful. That said, neither will I pat you on the head and tell you it's going to be alright with no effort on your part -- that wouldn't be fair to you. There are a lot of great contributors here (like Duane); look at everything they post and it will ultimately make sense. Any person that you are learning from has gone through what you are now.
Since you're playing with PST (not my usual choice), let me show you how you can extend the control you want with features that are built into that object. This bit of code uses single letter commands (as you did), and allows you to enter a specific pin #.
Note that by using the decin() method, you can specify any pin -- no need to have a letter per pin. This structure always wants a command and a pin.
To turn on the P26 LED on a PAB you would enter (without the quotes) "h 26" and then press [Enter].
The next step is to modify this program so that the letter will call a method that will accept the number of parameters required for it (0 to n...) -- this is when it starts to get fun.
I will try the things you posted.
There is a free "Basic" called RobotBasic that has serial methods built in for communicating with microcontrollers. It is located at robotbasic.org/
There is a free tutorial and a number of not-free books, including one that is targeted at the propeller (A Hardware Interfacing and Control Protocol using RobotBasic and the Propeller Chip).
Serial connections can be made between the computer with RobotBasic and the Propeller using wired or wireless methods.
One use is to collect information and save it with the propeller, then send it to RobotBasic where it is processed and displayed or saved for use in other PC programs.
tom
That sounds like the thing