digital Write on Ports | Arduino Compatible Compiler for LabVIEW Discussions | Forum

Avatar
Please consider registering
guest
sp_LogInOut Log In sp_Registration Register
Register | Lost password?
Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Feed Topic RSS sp_TopicIcon
digital Write on Ports
May 9, 2016
12:01 pm
Avatar
viwoi
Member
Members
Forum Posts: 16
Member Since:
March 19, 2015
sp_UserOfflineSmall Offline

Hello,

 

ist it possible to write the ports "K" or "F" on Arduino Mega (using analog ports for digital output)?

here is an example of source code:

void setup() {
for (int i= 1; i<100; i++)
{
pinMode(i, OUTPUT);
}
DDRF = B00000000;
}

void loop() {
PORTF = B11111111;
delay(1000); // wait for a second
PORTF= B00000000;
delay(1000); // wait for a second
}

 

Greetings, Vitali

May 9, 2016
8:18 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

You should be able to using Digital Write Port.vi.  Take a look at the documentation.  You only need to specify the start pin and the all bits in the corresponding port will be updated with the given value.  Make sure to set all pins as an output first.  You can also refer here for the mapping of pins to ports on the Mega.  I think you are interested in pins 82-97.

May 10, 2016
6:52 am
Avatar
viwoi
Member
Members
Forum Posts: 16
Member Since:
March 19, 2015
sp_UserOfflineSmall Offline

Hello Stefan,

 

the pin-number, that has to be set in the digitalWritePort.vi, seems to correspond to the mapped digital pin (e.g. portA is switched by the start pin "22", not "78"). An analog pin doesn't have an digital port mapping.

Setting of pins 82-89 for analog port using doesn't work.

May 10, 2016
2:19 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Take a look at digital_pin_to_port_PGM[] in \Arduino\hardware\arduino\avr\variants\mega\pins_arduino.h.  This defines the mapping of pin number to physical port for the Mega.  It appears Port F starts at pin 54 and Port K starts at pin 62.  You actually want to use the Mapped Pin Name in the link above in which the digital version of the analog pins start their numbering after the last digital pin in the list (53) but its not explicitly listed there so you have to go to the header file.

May 10, 2016
2:43 pm
Avatar
viwoi
Member
Members
Forum Posts: 16
Member Since:
March 19, 2015
sp_UserOfflineSmall Offline

Great! it works!

 

unfortunatelly I made meanwhile a workaround with user-code-implementation (created some functions & VIs for port setting).

It took some time, but on the other hand, I could practise in creating user codes 🙂

December 25, 2017
5:47 am
Avatar
NealXu
New Member
Members
Forum Posts: 1
Member Since:
December 25, 2017
sp_UserOfflineSmall Offline

Hi...i am a new user here. As per my knowledge you should specify the start pin and the all bits in the corresponding port will be updated with the given value.  Make sure to set all pins as an output first.  You can also refer manual for the mapping of pins to ports on the Mega.

high volume pcb assembly

Forum Timezone: UTC 0
Most Users Ever Online: 100
Currently Online:
21
Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
miche91: 33
scottj: 28
scadao: 23
Member Stats:
Guest Posters: 5
Members: 202
Moderators: 0
Admins: 3
Forum Stats:
Groups: 1
Forums: 2
Topics: 266
Posts: 1222
Newest Members:
pujacontrol
Administrators: geadmin: 22, filipealtoe: 96, Steffan: 356