Switching to the SX
Jonb
Posts: 146
Well I finally got around to ordering a SX/key deluxe kit from Digikey.
Unfortunately they have a 6 week lead time...
I've been prompted to make the move to the SX because a new project I'm working on. Basically a tracked autonomous robot.
I have been using the BS2sx to make prototypes and test concepts with great success. I have a few questions about the SX and I hope someone can answer them.
Firstly, I have a need to control DC Motors with PWM and an dual H-bridge circuit. My problem with the BS2 is that i can't output continuously a PWM signal without dedicating the module to this task. Can the SX perform tasks in the background? Ideally I would like to have a SX dedicated to motor control, another for navigation and sensors(ultrasonic,GPS).
Secondly, Is there a Canadian supplier that holds stock of the SX IC's so I dont have to wait 6 weeks lead time?
Thanks for your feedback.
Jon
Post Edited (Jonb) : 2/24/2005 2:41:09 PM GMT
Unfortunately they have a 6 week lead time...
I've been prompted to make the move to the SX because a new project I'm working on. Basically a tracked autonomous robot.
I have been using the BS2sx to make prototypes and test concepts with great success. I have a few questions about the SX and I hope someone can answer them.
Firstly, I have a need to control DC Motors with PWM and an dual H-bridge circuit. My problem with the BS2 is that i can't output continuously a PWM signal without dedicating the module to this task. Can the SX perform tasks in the background? Ideally I would like to have a SX dedicated to motor control, another for navigation and sensors(ultrasonic,GPS).
Secondly, Is there a Canadian supplier that holds stock of the SX IC's so I dont have to wait 6 weeks lead time?
Thanks for your feedback.
Jon
Post Edited (Jonb) : 2/24/2005 2:41:09 PM GMT
Comments
My interest also lies in auto robots. If you have an assembly language background, I would suggest reading the Programming the SX Microcontroller book by Dauback. He has a chapter, Robotics - Controlling the Parallax SX Tech Bot that deals with just that.
Perhaps I should clarify my question, Is the SX capable of outputting a PWM signal whilst performing other tasks? Is is capable of outputting many simultaneous PWM signals? Can this be implemented in code or is it hardware?
Jon
Post Edited (Jonb) : 2/24/2005 3:35:31 PM GMT
If you write a small scheduler controlled by the RTCC interrupt, then you can run several "simultaneous" threads; giving each one a small slice of time.
If you do it properly, you can output several PWM, serial UART, I2C, SPI and many others all at the same time.
Peter
recently, I have developed a triple motor control unit with an SX 28. You can find more details here:
www.parallax.com/sx/projects/projects_pwm.asp.
Seems as if your project has many similarities to what I had to do.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
It would seem that is exactly what I was looking for in terms of information Peter, thank you. The SX seems to offer much flexibility. I am eager to start coding.
Guenther: Thank you for the link, I will read it with great interest.
·
I believe that in one of your other posts you mention an RTOS (fancy scheduler). Have you considered making that code and/or some examples of 'multitasking' availble on this site? I believe a lot of people, including myself, are looking for examples, in the form of code.
isrtimer ds 1
org 0
inc isrtimer
;here goes code that runs every isr
mov w,isrtimer
and w,#3 ;use 7 for 8 threads, 1 for 2 threads etc
add pc,w
jmp isr_thread0
jmp isr_thread1
jmp isr_thread2
jmp isr_thread3
isr_thread0
;here goes code for thread0
jmp isr_thread_end
isr_thread1
;here goes code for thread1
jmp isr_thread_end
isr_thread2
;here goes code for thread2
jmp isr_thread_end
isr_thread3
;here goes code for thread3
isr_thread_end
mov w,#-intperiod
retiw
regards peter
Steve
It's not as if knocking out a scheduler is any great hardship, and it does mean that I now know exactly how mine works.
However, since the VP concept was a sales tool to allow plug&play(ish) software peripherals, to tease me with their existence, and then take it all away again with pointless copyrights, still grates...
(I note that Parallax sample code is much more sanely delivered. Thanks, chaps!)
Steve
Did you ask Ubicom about using their code? The fact that their code is copyrighted does not necessarily preclude its use. You need to ask the copyright owner, and if use is allowed, you need to know under what to terms. It may well be that Ubicom allows full use of their code for whatever purpose, as long as you don't copy it and claim it as yours and / or sell it outright.
Do not assume that just because source code does not contain the copyright statements that it is not protected. When copying code from a source, especially for commercial use, you need permission from the original author. For example, while Parallax may not state "copyright" in their code, that does not mean they have no rights in regards to its use. Jon and I exchanged emails about this in which he confirmed that Parallax's view is that is freely available for use as long as you don't sell it outright.
Vendors of hardware products very frequently provide sample source code. They copyright it to protect their interests. But I've never heard of a vendor precluding the use of sample code in conjunction with their device.
Jim
Yes, I asked, and the company we were designing for (who were purchasing the silicon) asked. (Only in email - no lawyer-letters)
Permission was not forthcoming - simply silence. We were surprised, but we were in a hurry, and had product to ship.
(From my position, at the bottom of the food chain, getting support for the SX during the Scenix -> Ubicom transition was rather trying. I'm just the hardware guy, though - so most of what I wanted was either in the data, or could be measured. (we were building DACs, and cared about the pins more than most).
That was back in <digs out ancient PCB> 1998 / 99. Things are vastly easier now - which is why I'm playing with software on the SX. (Run away - hardware guy doing software - ugly, ugly code ahead [noparse]:)[/noparse]
As for the Parallax source code, if Parallax are retaining rights to it, I do wish they'd state that explicitly. IP's tricky, and I really don't want to (unknowingly) infringe. To be honest, though, I'd prefer they state that it's fair game, and let me do whatever I want, whether that's splicing bits of it into my work, dropping it into projects developed under random other licenses, or printing it out and using it as wrapping paper.
However, Parallax wrote it, and can do whatever they like. I fully accept that.
(I'm just feeling a bit pressured, since the competition entry date is fast approaching, and chunks of code I'd been hoping to swipe, I'm having to reimplement, to nobody's gain, simply because of unclear (to me, at least) copyright protection.)
For instance - the competition entry - do you reckon that counts as 'commercial use'? There's a (dwindling) chance I could make financial gain from it. Am I expected to find a friendly IP lawyer to discuss this with? I'm just an engineer - the simpler my life is, the happier.
Steve
Ah, silence from an email... especially from a company in transition... That just means that either the guy that is supposed to be reading the emails got laid off, or their admin person responsible for the server did. It is amazing how many companies, even big ones, have published email addresses and don't respond to inquiries.
In regards to Parallax, or any other company, you just need to check on what terms the code may be used, then comply with it. It would be good if all hardware companies who posted sample code had a page on their website explaining the terms under which they can be used. Specifically about Parallax, Jon told me that I was free to use any code however I wanted as long as I didn't copy it and sell the code itself. That is very open and free. The "right" that they are retaining is to prevent somebody from, in essence, stealing their code and selling as their own. There is nothing in that, that precludes you from incorporating entire segments of code into your product. They just don't want to see Joe's Software Company selling a CD full of their application source code for the Stamp for $29.99 on eBay.
Unfortunately life in the software world is becoming increasingly difficult. We have things like Microsoft trying to patent the 'IsNot' clause in the BASIC language, as well as many other dubious software based patents. My biggest fear is getting a product developed and on the market only to get a letter from the lawyer of one of these IP companies (no products, just a long list of granted patents) saying that I'm infringing on one of their patents and I should pay up. I don't have the money for an IP lawyer, as is the case I suspect, with most small developers. So it is a risk we take.
Jim
"The information, applications and program code contained in this website are presented for instructional value and not guaranteed for any particular purpose. Parallax, Inc. does not guarantee the accuracy, adequacy or completeness of any information therein and is not responsible for any errors or omissions. Parallax Inc. assumes no liability for damages resulting from the use of the information, applications, and program code in this website, or for any infringement of patent and/or other intellectual property rights of third parties that would result from the use of this information."
which seems to mean that I can't complain if the code's bust, or not OK for P. to distribute - fair enough. No mention of letting me use the sample code for anything except instructional value.
Sure, I could ask Parallax for permission to use each specific file, in the manner I intend to use it, but that's going to get dull for both sides pretty soon. Re-asking, when I want to do something different, even more so.
An explicit statement, especially in files to which Parallax have clear ownership, (say, in
http://www.parallax.com/dl/sw/sx/SXCodeTemplate.src - which is the sort of file that is the most clear-cut - and in which I'd taken the lack of copyright message of any sort to mark it as fair game) would make me worry less.
While I'm almost certain that nobody's going to come after me for using it, changing it, and selling it as my own work, it would be nice to _know_.
(And yes, those IP-chasing companies do annoy me. Imagine if Parallax got bought out by one, and started chasing people. Unlikely, but - eek).
Steve. (Engineer IsNot <ahem> lawyer)
"Parallax grants you a limited license to access and make personal use of this site and not to modify any portion of this site."
Oops. (been modifying the code templates)
"This site or any portion of this site may not be reproduced, duplicated, copied, or otherwise exploited for any commercial purpose without express written consent of Parallax."
Oops. (if the competition entry is 'commercial purposes'. Dunno).
I probably ought to ask Parallax for some permission, or at least clarification. (and my Place&route's done, so I probably ought to do some work, too [noparse]:)[/noparse]
Steve
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james@sxlist.com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!
First smile of a long, long day - thanks!
Steve
All of our code can be used, modified and copyrighted by our customers. We're not in the business of selling code. Any code on the Ubicom web site is yours for the modification. They're very cooperative in this regard. Feel free to remove our copyright message from any code template, change it, and copyright it for yourself. The only code we protect is not available on our web site anyway (SX-Key, Stamps, etc.).
And for the lawyers, fat chance you'll ever hear from ours because we don't have any. We·don't think·too much of legal professionals around Parallax.·That's the benefit of a small company - no legal department to help us through our daily business or to contribute keywords to our business agreements.·Our most common use of legal professionals is to obtain registered trademarks.
Sincerely,
Ken Gracey
Parallax, Inc.
(I take it that Ubicom have the rights to give away the old Scenix-marked stuff too? )
Cheers, and thanks for the quick and thorough response. It's a pleasure to deal with a sane company.
Steve
Yes, Ubicom owns all IP of Scenix. Same company, some same employees, different name, with a different R&D focus than they used to have with the SX. But the code examples are not part of their "IP" investment. Even if they were, these examples have been in the public domain so long it would be tough to claim any kind of ownership. They just want you to buy the chips.
We will remain sane. We've been sane for 15 years now. The day we go insane we'll probably post our own IP on the web. . .
Ken Gracey
Parallax, Inc.
So I understand how to output a PWM signal at a specific frequency, but the math is still tricky. With the books packaged in the kit I will no doubt have many questions answered.
So ok you can control the frequency on an output pin, but how do you modify the PWM singal to ramp speed without affecting other independant PWM signals and any communication peripherals. how do you get many RTCC interrupts running at once.
Each channel has a setpoint variable that you change to set it's output level.
You basically set the interrupt period for the PWM frequency you want * 256, then inside the interrupt you add the output value to an accumulator variable for each output, If the acumulator overflows you set the output high, if not you set the output low.
It's that easy. Now if you want different PWM frequencies for different channels that would be somewhat harder.
Up to 8 channels can be handled easily by a 50MHz SX chip at a reasonable PWM frequency.
Let's say you wanted a PWM frequency of 1KHz, you would need a interrupt frequency of 256KHz so you would set the RTCC reload value to 195 for a 50MHz clock (50MHz / 195 = 256410 Hz / 256 = 1001.6Hz ).
Then inside the interrupt routine do something like this:
ADD PWMAccum,PWMValue
MOVB PWMOutputPin,C
That's all there is to it. Just change the PWMValue variable to set the PWM level.
If you want to try it in the simulator it might be easier to just put the instructions inside a loop (instead of an interrupt), so see how it works.
EDIT
· Note that the above method of PWM is like the PWM in the Basic stamp (good for converting to analog, but it's not for motor control).
· For that you need a little more code.
··· You need to increment the accumlator and see if it is less than or greater than the setpoint (PWMValue).
· INC PWMAccum
· MOV W,PWMAccum
· MOV W,PWMValue-W ; We don't care about the result just the carry bit
··MOVB PWMOutputPin,C
· That code is untested, but I think it will work.
·
··
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out· the "SX-Video Display Module"
www.sxvm.com
Post Edited (Bean) : 3/1/2005 3:35:28 AM GMT
Thanks,
Jon
Post Edited (Jonb) : 3/1/2005 4:20:21 AM GMT
You can change the RTCC interrupt period on-the-fly for example.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out· the "SX-Video Display Module"
www.sxvm.com
·
-1 I2C channel(slave).
-2 PWM channels for 2 DC motor control
The SX28 would accept commands·via I2C(and parse them)such as forward, reverse, right, left but would also do turns while moving forward or reverse at specified or default values depending on current state.
Post Edited (Jonb) : 3/1/2005 4:43:57 AM GMT
I have just submitted my contest entries, and it may have some relevant examples and explanation.
If I am fortunate enough for them to select it for demonstration then it should show up on their website.
If not, then I would be happy to share my knowledge on this with you.
The examples demonstrate a simple non-preemptive scheduler as well as a priority based approach.
Peter
Post Edited (Jonb) : 3/1/2005 4:56:39 AM GMT
Does not sound too difficult.
k
Digikey's 6 week lead time turned into 2 weeks as it was shipped out today!
Looking at the details the price I paid for the "deluxe" sx kit was
123.20$CA. Thats a hot deal!
Post Edited (Jonb) : 3/2/2005 9:40:30 PM GMT
Jim