View unanswered posts | View active topics It is currently Mon Sep 01, 2014 5:03 pm






Reply to topic  [ 4 posts ] 
Direct port access? 
Author Message
Rookie

Joined: Sun Feb 03, 2008 3:16 am
Posts: 2
Post 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
Profile
Expert
User avatar

Joined: Fri Nov 09, 2007 4:51 am
Posts: 121
Location: Hungary, Europe
Post 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
Profile
Rookie

Joined: Sun Feb 03, 2008 3:16 am
Posts: 2
Post 
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
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 615
Post 
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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.