Wednesday, February 10, 2010

and Failure!! Well, not exactly. My original NXT project has worked beautifully and my lab is going off without a hitch . . . at least for those 2 setups. I was hoping that with the same amount of work I could get it running on an RCX. I didn't really think through the project much as I was on deadline for the lab. After spending a lot of time figuring out how to get leJOS on the RCX, and getting the IR Tower to work correctly I ran into a brick wall. That brick wall was in a method called .setPower(). The problem wasn't that there didn't exist a .setSpeed(), I was ready for that since the RCX motors don't have a tachometer built in. That's why I bought a rotation sensor. The problem was that .setPower() only operates on a range from 0-7 unlike .setSpeed() which works from 0-900 deg/sec. The power setting isn't even a linear relationship. After a lot of digging through different languages I couldn't find one that would give me the resolution that I'm looking for, so I'm left with creating my own Pulse Width Modulator. The RCX uses PWM already, but it is over an 8msec interval (thus the 0-7) power setting. I'll have to extend the width in order to make this work, and control the pulse manually. This means that the number of msec that I make the width is equal to my resolution for frequency control (which I still have to calculate and have indirect control of). But the wider I make the width the more difficult the problem becomes. If the width is too long then I can't just have the motor run hot for the duration and cold for the rest. If I want a duty cycle of 2% for a 100msec cycle then I should ideally run hot for 1msec, cold for 49msec then repeat. But that requires a more complicated algorithm that figures out the number of times to run hot for 1msec. It's not that I can't do it . . . it isn't going to be that difficult . . . but I'd rather just leave it as an easy "hot for x, cold for 100-x" system. Anyway, due to these problems I have bought one more NXT brick and will probably buy a new kit next year. Bummer, but at least I'm learning things.



Post a Comment

<< Home