Author Topic: Char to I/O  (Read 1660 times)

0 Members and 1 Guest are viewing this topic.

PAT_McUser

• Jr. Member
• Posts: 32
• I just started with robitic.
Char to I/O
« on: October 24, 2009, 02:17:39 PM »
hi,
I think my new problem is some easy basic stuff.
Today I need some help by translating some chars in boolean variables.
So I have some char, maybe we take a 'm' the Hex code is 6Dh and I need the binary of its (0110 1101).
I have some Functions D0(boolean),...,D7(boolean) which control the outputs of my Axon, if I give my function the char It should be set like this:

Code: [Select]
`D0(1);D1(0);D2(1);D3(1);D4(0);D5(1);D6(1);D7(0);`
How can I get this, thanks for help.
I just started with robitic.

PS.: you have to sorry my bad english.

chelmi

• Supreme Robot
• Posts: 496
Re: Char to I/O
« Reply #1 on: October 24, 2009, 02:31:34 PM »
Let me rephrase your question to be sure I understand.
You want to get each individual bit of you char to be written on the D port of your Axon?

There is a very easy way to do this if you don't use the D0...D7 function:

PORTD = 0x6d;

or if you have a char variable named my_char:

PORTD = my_char;

I you really need to use you functions, you will have to play with bit masks. to extract each bit of your variable.

Chelmi.

PAT_McUser

• Jr. Member
• Posts: 32
• I just started with robitic.
Re: Char to I/O
« Reply #2 on: October 25, 2009, 02:57:35 AM »
Thats nice to know, I think I'll need this in the future.
It's not that nice, D stands for Data. I want to use the a2d-Pots to send signals with 5 volt. If I'm right The other ports have nearly the voltage of the axon supply (I use a 7.2 volt battery). The device I want to talk with goes broken if I power up more than 5 volt. Thats why I use the functions, they control the voltage of the a2d.
I just started with robitic.

PS.: you have to sorry my bad english.

chelmi

• Supreme Robot
• Posts: 496
Re: Char to I/O
« Reply #3 on: October 25, 2009, 10:02:33 AM »
Thats nice to know, I think I'll need this in the future.
It's not that nice, D stands for Data. I want to use the a2d-Pots to send signals with 5 volt. If I'm right The other ports have nearly the voltage of the axon supply (I use a 7.2 volt battery). The device I want to talk with goes broken if I power up more than 5 volt. Thats why I use the functions, they control the voltage of the a2d.

no no no, the axon may be supplied with 7.2 V, but it has a voltage regulator to power the ATmega with 5.0V. Look at the datasheet of the ATmega 640 and you should find the maximum operating voltage which is aroung 6V. More than that and the ATmega will fry... digital I/O are 0 - 5V, you can use them directly.

I don't understand what you're trying to do with the analog to digital (ADC) ports, these are inputs. I think you got confused with the power bus which is directly connected to your battery (see the axon datasheet).

PAT_McUser

• Jr. Member
• Posts: 32
• I just started with robitic.
Re: Char to I/O
« Reply #4 on: October 25, 2009, 02:32:36 PM »
okay... ...if all I/O's have maximum 5-6volt than I can use the standart standart ports to wire up. But there is still the problem: I can only send 4 bit at once (I use a 4 wire connection) so I need to store the other 4bit and send them in a second step.

I thought the ATMega has a 5 volt logicalvoltage and a higher output (regulated with some transistors which direct contactde the Port with the capacitor and the battery), my intention was that the ADC's are able to putout some variable Voltage.
Sorry my studies wasn't so intensive... ...but I had some more problems with the connection of the device (Display) without destroying existing hardware. All I had done in programmingstuff was to write down some pseudocode for initialing and transferring prepared data.
« Last Edit: October 25, 2009, 02:35:21 PM by PAT_McUser »
I just started with robitic.

PS.: you have to sorry my bad english.

• Supreme Robot
• Posts: 11,702