Shop OBEX P1 Docs P2 Docs Learn Events
Switching to the SX — Parallax Forums

Switching to the SX

JonbJonb Posts: 146
edited 2005-03-02 21:38 in General Discussion
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
«1

Comments

  • RsadeikaRsadeika Posts: 3,837
    edited 2005-02-24 15:14
    Jon
    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.
  • JonbJonb Posts: 146
    edited 2005-02-24 15:30
    I will receive that book in 6 weeks. It is not offered in PDF format so I do not have access to it.

    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
  • pjvpjv Posts: 1,903
    edited 2005-02-24 15:35
    Hello Jon;

    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
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-02-24 15:41
    Jon,

    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
  • JonbJonb Posts: 146
    edited 2005-02-24 15:42
    pjv said...


    If you do it properly...
    ·

    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.

    ·
  • RsadeikaRsadeika Posts: 3,837
    edited 2005-02-24 15:48
    pjv,
    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.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-02-24 15:54
    Here is an outline how to code threads in the isr

    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
  • SteveWSteveW Posts: 246
    edited 2005-02-24 16:20
    The Ubicom / Scenix source code that's in their VP application notes is (extremely irritatingly, and rather pointlessly) copyrighted, all rights reserved. I've got no idea why they thought this was a good idea, and it forced me to write my own scheduler from scratch - a complete waste of effort. <end rant>

    Steve
  • SteveWSteveW Posts: 246
    edited 2005-02-24 16:27
    Sorry, that was probably excessively ranty [noparse]:)[/noparse]
    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
  • Jim McCorisonJim McCorison Posts: 359
    edited 2005-02-24 16:50
    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
  • SteveWSteveW Posts: 246
    edited 2005-02-24 17:16
    Hi,
    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
  • Jim McCorisonJim McCorison Posts: 359
    edited 2005-02-24 17:48
    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
  • SteveWSteveW Posts: 246
    edited 2005-02-24 18:17
    Well, Parallax do say:
    "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)
  • SteveWSteveW Posts: 246
    edited 2005-02-24 18:46
    Also from the 'terms of use' page:

    "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 NewtonJames Newton Posts: 329
    edited 2005-02-24 19:54
    Ok, All together folks: What do you call 1,000 laywers at the bottom of the ocean?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ---
    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!



  • SteveWSteveW Posts: 246
    edited 2005-02-24 20:06
    [noparse]:o[/noparse])
    First smile of a long, long day - thanks!

    Steve
  • Ken GraceyKen Gracey Posts: 7,401
    edited 2005-02-24 21:37
    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.
  • SteveWSteveW Posts: 246
    edited 2005-02-24 21:52
    Thanks hugely! I'll stop fretting (about that, at least. This poxy Xilinx still won't work, but that's unlikely to be a lawyer-problem [noparse]:)[/noparse]

    (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
  • Ken GraceyKen Gracey Posts: 7,401
    edited 2005-02-24 22:04
    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.
  • JonbJonb Posts: 146
    edited 2005-03-01 01:56
    I've been looking at alot of code and running it on SXSim, what a great tool. Cant wait to get the kit .
    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.
  • KenMKenM Posts: 657
    edited 2005-03-01 03:24
    Very carefully!!!!!!!!!!!!!
    jonb said...
    i've been looking at alot of code and running it on sxsim, what a great tool. Cant wait to get the kit .
    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.
  • BeanBean Posts: 8,129
    edited 2005-03-01 03:26
    It's pretty easy to have multiple PWM channels handled by one interrupt routine.

    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
  • JonbJonb Posts: 146
    edited 2005-03-01 04:13
    So there is one RTCC interrupt, but each frequency independant task is scaled? I would then suppose that the main RTCC is scaled to the fastest frequency needed, and the scaled RTCC tasks can be modified on the fly? Does anyone know of an example I could refer to?

    Thanks,

    Jon

    Post Edited (Jonb) : 3/1/2005 4:20:21 AM GMT
  • BeanBean Posts: 8,129
    edited 2005-03-01 04:16
    What exactly are you trying to do ?
    You can change the RTCC interrupt period on-the-fly for example.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out· the "SX-Video Display Module"

    www.sxvm.com
    ·
  • JonbJonb Posts: 146
    edited 2005-03-01 04:33
    Trying to initiate myself to the SX by getting 2 motors to work using a dual H-bridge circuit. The 2 motors feed a·Leclerc tank model·I'm hacking into a tracked base.

    -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
  • pjvpjv Posts: 1,903
    edited 2005-03-01 04:47
    Hello Jon;

    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
  • JonbJonb Posts: 146
    edited 2005-03-01 04:53
    pjv said...

    Hello Jon;

    I have just submitted my contest entries, and it may have some relevant examples and explanation...

    ...The examples demonstrate a simple non-preemptive scheduler as well as a priority based approach.

    Peter



    Any example you or others could provide of their code is a benefit to all. I have no doubt this contest·will increase the·SX content.·What I am trying to do isnt complex. I just havent come across any examples(I can imagine many ways of implementing this, but i'm searching for the most efficient method).·Oh ya and good luck to all those who entered, I am interested in·reading about·your creations.

    Post Edited (Jonb) : 3/1/2005 4:56:39 AM GMT
  • KenMKenM Posts: 657
    edited 2005-03-01 04:58
    Thanks Bean,

    Does not sound too difficult.

    k
  • JonbJonb Posts: 146
    edited 2005-03-02 21:34
    An update on the SX kit I ordered.

    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! jumpin.gif



    Post Edited (Jonb) : 3/2/2005 9:40:30 PM GMT
  • Jim McCorisonJim McCorison Posts: 359
    edited 2005-03-02 21:37
    Right now Parallax has the "Pro" kit (I think that's the same as the Deluxe) on sale for 99$US, so that probably translates out about the same price.

    Jim
Sign In or Register to comment.