Re-discovering Spin
Rsadeika
Posts: 3,837
Yesterday I got a package from Parallax, which contained, among other things, an HIB board for my QuickStart board. Since I have not used Spin in quite awhile, I thought I would offer up my rendition of a beginners program. I am using the PropellerIDE for this, because it is the latest and the greatest.
The objects that come with an installation of PropellerIDE pretty much covers all the components that are on an HIB, except for one, the uSD card. I did not see any object or DEMO program that would show how to use this. I am sure that this oversight will be corrected in a short time, I hope.
I am also wondering if a specific object should be made that would contain all the methods for using all the components on the HIB, that way you could just use a command format to implement the specific component, just a thought.
Ray
The objects that come with an installation of PropellerIDE pretty much covers all the components that are on an HIB, except for one, the uSD card. I did not see any object or DEMO program that would show how to use this. I am sure that this oversight will be corrected in a short time, I hope.
I am also wondering if a specific object should be made that would contain all the methods for using all the components on the HIB, that way you could just use a command format to implement the specific component, just a thought.
Ray
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '' test1.spin '' Setup QuickStart board with HIB CON _clkmode = XTAL1 + PLL16X _clkfreq = 80_000_000 OBJ '' misc : "tools" '' Commonly used methods object term : "Parallax Serial Terminal" '' Access the debug terminal ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' PUB Start term.Start(115000) '' Initialise the debug terminal term.str(string($d,"The blinker program.",$d)) '' Header message main ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' PUB main repeat blink ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' PRI blink high(16) '' Turn on LED P16. waitms(500) '' Pause for half a second. low(16) '' Turn off LED P16. waitms(500) '' Pause for half a second. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '' These methods would be kept in a seperate object '' '' How to use - wait(1) '' Pauses for one second PUB wait(time) waitcnt((80_000_000 * time) + cnt) '' This method has a roll over '' when set for greater than 53 seconds. ''''''''''''''' '' How to use - waitms(1000) '' Pauses for one second PUB waitms(time) waitcnt(((80_000_000 / 1000) * time) + cnt) '' This method has a roll over '' when set for greater than '' 53 seconds. ''''''''''''''' '' How to use - high(0) '' Set high P0 PUB high(pin) DIRA[pin] := %1 OUTA[pin] := 1 ''''''''''''''' '' How to use - low(0) '' Set low P0 PUB low(pin) DIRA[pin] := %1 OUTA[pin] := 0 '''''''''''''''
Comments
No. As an example... what protocol would you select for IR in and IR out? Sony? Panasonic?
Creating an object for everything on the HIB just means bloated code; go with individual objects for the pieces that you're using on the HIB for a given project.
I am now using my tools object, so if anybody is playing along, you will have to make that happen in your Spin rendition.
Ray
For the benefit of some new people, kuroneko, is a Master Guru, in Spin, PASM, and I can only guess at what other programming languages. JonnyMac is more Spin/PASM, plus their are others.
Since I setup my QS_HIB to do some prototyping, the next thing I might try is adding an XBee module and do some IO with that, not sure though.
Ray
Obviously creating IDE archive/zip buttons is a waste of time.
For example:
BTW, I tend to use 16 as my minimum stack size for a simple cog -- crashing the stack is a real nasty bit of business.
TIP: When I have methods in my main program that are going to launch into a cog (as above), I declare them as private to remind me not to call them as standard methods.
Ray
From ObEx that may be helpful:
-- http://obex.parallax.com/object/319
-- http://obex.parallax.com/object/321
Ray
I have a "Glow with the Show'" hat from Disneyland that uses serial over IR (2400 baud) and I've used my HIB to control the hat. Disneyland uses the Propeller in several small projects and this year I will help them revamp a display -- we'll probably throw GWTS hat control in as well.
Ray
I tried to use some of the screen control commands, I was not getting what I expected. For instance, I tried to use the GOTOXY, to place the next read out after the banner, for what ever reason it clears the screen and then nothing shows up after that. Something as simple as that, and I seem to have a problem figuring it out.
I guess the next thing is to create a program that has a remote keypress and a designated HIB LED turn on/off. The key to this is to have an object that has all the decimal key values and a response to each key press.
I was thinking of a project where I would have these different devices in a room, and I would control them with an XBee, now I am thinking if you have one master with an XBee and IR, then I could control the other devices with the IR. Line of site for the IR, I guess I could point the master device at the ceiling and that should alleviate that problem somewhat.
Ray
When I need to move the cursor to a specific position (I do a lot of formatted output) I tend to add a method like this:
The only mods that I made to the jm_sircs program was, adding a dec and a hex listing along with the binary that you got originally. Somewhere along the line I will probably add a column header that labels the information, so you know what you are looking at.
The td_sircs program was changed to run with the PropellerIDE, and I found it easier to figure out how to assign some code for the TV remote controller keys. I tested all the keys out with the LED on/off commands. This program is different from the jm_sircs, it does not "sniff" out the controller key codes.
The knk_vga80x25 program is a plug and play demo, it worked with the PropellerIDE and the QS_HIB without a hitch, did not have to change one bit of code to have the demo run. On my 19" widescreen TV set with a vga plug, the characters displayed were very nice, even when the whole screen is filled. Now I have to look into creating an object that has a command structure so I can make it work in place of the "Parallax Serial Terminal".
Somewhere along the line I will probably add a keyboard, once I figure out how the implement the knk_vga80x25 diver to work with it. But first I will try having the td_sircs display a message with a keypress of the TV remote controller, to the TV monitor. So far the one thing that I am missing is some ADC sockets, not sure if I have enough resources left on the QS_HIB to implement that. Now if Parallax could do a cost reduction on the QS_HIB, I think this combo has a lot of potential.
Ray
Ray
Now I guess I can experiment with the uSD. The one thing that I noticed was, for PropGCC the driver size was about 9K, and for Spin the size is about 7K, I was under the impression that it would be way smaller for Spin.
The other thing that I noticed, with the HIB installed, when you apply power via the barrel socket, and you have the USB plugged in, when I try to program the chip, PropellerIDE comes back with a "Cannot find a Propeller chip". As soon as I unplug the power from the barrel socket, then the PropellerIDE finds the Propeller chip, is that my board, or is that the way it supposed to work?
Ray
Ray