|
Page 1 of 1
|
[ 4 posts ] |
|
| Author |
Message |
|
jrmclaugh
Rookie
Joined: Sun Feb 03, 2008 3:16 am Posts: 2
|
 Direct port access?
I can't seem to find in the documentation, or anywhere else, if there's a way to directly assign a value to an output port. Say I want to create my own PWM, using a timer and a single bit assignment at the end of the timer. If there is a way, what is the syntax? Thanks.
- James
P.S. Let me know if that wasn't clear, things often make sense a certain way in my head and I don't end up explaining enough. thanks.
|
| Sun Feb 03, 2008 3:19 am |
|
 |
|
elemes
Expert
Joined: Fri Nov 09, 2007 4:51 am Posts: 121 Location: Hungary, Europe
|
 own pwm
Hello,
I don't think RobotC is fast enough for this task. The finest time resolution it supports is 1 msec thus you can switch off and on the output up to 500 times a second. Such tasks like pwm are either implemented in hardware or in the firmware (executed directly in the ARM microprocessor machine language).
RobotC bytecode execution time is a few microseconds for simple integer operations, this also limits the number of instructions executed by a periodic task.
|
| Sun Feb 03, 2008 3:23 pm |
|
 |
|
jrmclaugh
Rookie
Joined: Sun Feb 03, 2008 3:16 am Posts: 2
|
Thank you for the reply. That's unfortunate. I was hoping to get more direct access to the hardware. I wasn't actually planning on writing my own PWM, just write a way to communicate with a chip that doesn't use I2C. I guess the only way to do this is get an emulator and program the chips directly.
|
| Mon Feb 04, 2008 1:15 am |
|
 |
|
Dick Swan
Creator
Joined: Fri Feb 09, 2007 9:21 am Posts: 613
|
The motor PWM is actually managed by a small 8-bit AVR CPU that is controlled by the primary 32-bit ARM CPU on the NXT. The ARM sends messages (via an internal I2C bus) to the AVR containing PWM settings for the three motors. And the ARM reads I2C data from the AVR containing the analog sensor values and button depresses.
One I2C message is sent per millisecond with the ARM alternately updating motors and reading sensors. So the performance delay is not a ROBOTC timing issue but limited by the I2C messaging.
The NXT AVR scans the analog sensors on a 3-millisecond basis. Every analog sensor is read once every 3-msec.
|
| Wed Feb 27, 2008 11:05 am |
|
|
|
Page 1 of 1
|
[ 4 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 8 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|