Ybox2 Software Questions

Talk about YBoxen, widgets, Propeller hacking, etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Starcruiser1229
 
Posts: 2
Joined: Fri Jun 13, 2008 6:06 pm

Ybox2 Software Questions

Post by Starcruiser1229 »

I am planning on making a project sort-of based on the ybox2. I am hoping to create a stand alone display that uses a gauge, some lights, etc... to display info instead of a tv screen (although I am hoping to incorporate a tiny tv I have for debugging and more info...) I got the basic Idea a few months ago when make magazine used a microcontroller and an antique multimeter to create a 'new emails' display. I want to do this as sort of an intro project to micro-controllers. I am inexperienced with electronics in general, and my programing experience at this point is limited to Into to Java (so I hope I am not in too far over my head!)....

I am hoping that I can use the ybox2 code as a solid basis for what I want to do - I am looking at modifying the infowidget, to get text from a website I control, which will do the heavy lifting (I have no Idea how to write the php/cgi to do that at this point, but one step at a time...). I will run the bootloader more or less stock. I think I will rewrite Subsys almost entirely, to handle the hardware that I want to use - I am planning on one gauge (controlled via pwm), several lights and switches (controlled via 8255 chips), and possibly some nixie tubes (I am hoping for a vintage/antique/steampunk look when its all said and done...). I have a few questions that are specific to the Ybox2 code, and a few general questions about the propellor and spin code - I was hoping some more advanced people could help me out.

1) My understanding is that the bootloader loads the Stage 2 code 'over' itself, in cog 0, and shuts down. Hence, the stage 2 code has full control over whats running, but it also has to implement any webserver functions itself, as the bootloader has shutdown and so its server is no longer running- is this correct?

2)When the bootloader is up and running, how many cogs does it use? How about the Infowidget?

3) Any reason I couldn't use "Broadcast" tv instead of Composite (and how would I change the code/hardware to set this up - I am assuming it has to do with the way TV_Terminal is called or configured?) I would like to use a small lcd tv I already have - a handheld, battery operated model, and it does not have any inputs.

4)I am planning on using the "PPI8255" object from the object exchange to handle the IO chips, which at first glance seems easy enough - the one problem I have run into so far is that when I read (or write out) I have a byte of binary information - each bit in that byte represents the status or one IO pin on the chip. Is it possible to read just one bit from that byte with spin code? IE tell if the 'fourth' bit is on or off? This way I can check if one specific thing is on or off, and then deal with that (or, on output, set one specific thing on or off...). This seems like it should be possible, but I can't figure out how - Is there an elegant way to do this? The only other thing I can think of is to either handle all 255 possibilities (which seems like a waste of resources), or use "bitwise Encode" and "Bitwise Shift" to handle it somehow, but bitwise encode SAYS it works on a Long, and I am not sure if it would work properly on a Byte? I am sure that there is a simple way to do this, I just don't see what it is right now...

5) Can anyone point me to a solid primer on using the counters in PWM mode? I want to use the counter in the Subsys cog in PWM mode to handle the PWM for the gauge so I don't need to waste a whole cog to deal with it - any source code or some more specific info on how to set that up would be really useful...

6) I am assuming that I can 'parse' the info from the webpage somewhat simply on the propellor - IE if I have a column of a given number of values in text format, each of which represents something different. How hard is it to convert each one to a number and then store them into separate variables? It seems like it should be easy, but this is essential, so before I spend the time and money to do this, I just wanna make sure...
Example code would be awesome, if anyone has some, or a pointer to where the infowidget does its parsing - perhaps I can modify that...?

7) This isin't so much a question but: Anymore info on how Sybsys works, and why it works the way it does, would be helpful to me as I think I am going to try to more or less replace it, as the hardware I want to control is fairly different from what it was intended for. Or is that a bad idea? Also, on a more specific note, it says it encorporates a real-time-clock - how does that work? I don't think I need one, but it might be nice to have....

I realize that this is a huge list of questions, some of which are rather vauge, and I am sure I will only have more as this progresses, so any help at all would be greatly appreciated. I also hope this is appropriate for this forum - I know its not exactly all about the YBOX2, but it is based on the YBOX2, so...

Thanks!
Patrick

User avatar
darco
 
Posts: 118
Joined: Wed Jun 04, 2008 7:54 pm

Post by darco »

1) My understanding is that the bootloader loads the Stage 2 code 'over' itself, in cog 0, and shuts down. Hence, the stage 2 code has full control over whats running, but it also has to implement any webserver functions itself, as the bootloader has shutdown and so its server is no longer running- is this correct?
You are correct. The bootloader is completely replaced by stage2. All cogs and locks are reset.
2)When the bootloader is up and running, how many cogs does it use? How about the Infowidget?
I'm not really sure. I'll have to check.
3) Any reason I couldn't use "Broadcast" tv instead of Composite (and how would I change the code/hardware to set this up - I am assuming it has to do with the way TV_Terminal is called or configured?) I would like to use a small lcd tv I already have - a handheld, battery operated model, and it does not have any inputs.
I've never tried broadcast mode, but I don't see any reason why this wouldn't work. I'm sure someone on the propeller forum on the parallax website would know how to do this.
4)I am planning on using the "PPI8255" object from the object exchange to handle the IO chips, which at first glance seems easy enough - the one problem I have run into so far is that when I read (or write out) I have a byte of binary information - each bit in that byte represents the status or one IO pin on the chip. Is it possible to read just one bit from that byte with spin code? IE tell if the 'fourth' bit is on or off? This way I can check if one specific thing is on or off, and then deal with that (or, on output, set one specific thing on or off...). This seems like it should be possible, but I can't figure out how - Is there an elegant way to do this? The only other thing I can think of is to either handle all 255 possibilities (which seems like a waste of resources), or use "bitwise Encode" and "Bitwise Shift" to handle it somehow, but bitwise encode SAYS it works on a Long, and I am not sure if it would work properly on a Byte? I am sure that there is a simple way to do this, I just don't see what it is right now...
In general, this type of bit testing is handled by creating a "bit mask" and then ANDing that with the byte, and then checking to see if the result is zero or not. There is an easy way to access the pins for the I/O ports on the prop itself, but that technique doesn't work on other variables. The following expression would test to see if bit 6 is set in spin:

Code: Select all

var & constant(1<<6)
5) Can anyone point me to a solid primer on using the counters in PWM mode? I want to use the counter in the Subsys cog in PWM mode to handle the PWM for the gauge so I don't need to waste a whole cog to deal with it - any source code or some more specific info on how to set that up would be really useful...
Are you trying to use PWM for doing D-A conversion? If so, I've already got three analog-out channels in the subsys object which could be used for that purpose, and it would be really easy to add more.
6) I am assuming that I can 'parse' the info from the webpage somewhat simply on the propellor - IE if I have a column of a given number of values in text format, each of which represents something different. How hard is it to convert each one to a number and then store them into separate variables? It seems like it should be easy, but this is essential, so before I spend the time and money to do this, I just wanna make sure...
Example code would be awesome, if anyone has some, or a pointer to where the infowidget does its parsing - perhaps I can modify that...?
You may want to have a look at the original ybox source code, which has a simple CSV-like data parser.
7) This isin't so much a question but: Anymore info on how Sybsys works, and why it works the way it does, would be helpful to me as I think I am going to try to more or less replace it, as the hardware I want to control is fairly different from what it was intended for. Or is that a bad idea? Also, on a more specific note, it says it encorporates a real-time-clock - how does that work? I don't think I need one, but it might be nice to have....
The subsys object was is a kind of general purpose background assembly loop that does...stuff. Conceptually, it does the following:


* Outputs the appropriate duty cycle for each channel of the RGB LED.
* Increments a value in HUB ram exactly once every second (RTC)
* Monitors the button to see if it has been held down for longer than 5 seconds, and if so reboots the device. (currently disabled)

In the future, I also intend to add the capability of controlling the piezo from that cog as well.

The RTC is required for networking stuff to work properly. It is required because at 80MHz, using cnt variable will roll over at just over 60 seconds.

There are a few other points I wanted to elaborate on, but I need to move on to another issue in the real world. [/list][/quote]

Starcruiser1229
 
Posts: 2
Joined: Fri Jun 13, 2008 6:06 pm

Post by Starcruiser1229 »

Thanks for the info!! That is a huge help.

In terms of the SubSys object,
I am really not that familiar with Assembly at all, I would rather use Spin if I could - Do you think that could work?

I understand that the spin is much slower, but with the 8255 chips I am using for output you just set the value you want and then it will maintain it, and I doubt I will ever need to blink the lights faster than the spin loop can go. On a similar note I think I have figured out how to use the counter in Duty mode to drive the gauge directly, so I don't have to worry about the speed of the loop. (I have read there are some problems using duty mode for very high or low values, but I think it should work ok for this).

The audio you are using all seems to be under about 1/5 of a second, which should be ok, but if its not I can always spin off its own cog just for the time its playing, or use the second counter somehow...

The one thing I am not sure of is that RTC. If I understand it correctly you are essentially incrementing a Long sized variable once a second? The problem is waiting exactly a second without making the loop wait and do nothing for too long - I think it will definitely take less than a second to do the loop (I think....) I guess I could just check the CNT every time through the loop, and if it has been over 1 second increment the RTC, and since the CNT is good for 60 seconds, I could increment say by 2 every 2 seconds if I have a problem with the length of the loop? (I do not have the Prop yet so I have no idea how long this code will take to run)

If you don't think that would work, I guess I will have to start studying Assembly!

On a totally different topic -

Code: Select all

repeat
      if (in := \tel.rxcheck) => 0
        if in <> 10
          \term.out(in)
          i++
      else
        ifnot tel.isConnected
          if i > 1
            stat_refreshes++
            return WEATHER_SUCCESS
          abort 4
        if cnt-timeout>10*clkfreq ' 10 second timeout      
          abort(subsys#ERR_DISCONNECTED)
This code snippet is from the WeatherUpdate Routine in the InfoWidget - it looks to me like this reads in the text from the website letter by letter and prints it out to the terminal, as long as it is not an ascii char 10 (line feed).


If so, I think I can use this piece of code right here to do what I want: I have access to a server, so I can simply set up a separate script for each thing that I want to track, that simply returns a number - instead of testing for just line feeds I can check number by number and just store it out to a variable...

That is, of course, assuming I can figure out how to write the server-side scripts to do the parsing! (I have no experience with server-side programming... ) :shock: -- Can you tell me anything about the script you are calling by default to get the weather?

I just want to say thanks again for all of your help - I really appreciate it!

Patrick

Locked
Please be positive and constructive with your questions and comments.

Return to “YBox2 (discontinued)”