Seite 1 von 1
input HEX to program LED ATMega8 - Help ME
Verfasst: Mittwoch 26. August 2015, 08:48
von lukg20
Hello.
They're working on the device inputs and outputs USB-based microcontroller Atmega8. Share when I finish.
The unit will consist of modules that connect to his own personal experience bath.
When you create macros encountered a serious problem with access.
With RS-232 I get the value HEX 16-bit microcontroller input ATMega8. I can do so that the LEDs in the program work in turn. In the example I posted the switches that send HEX values corresponding to those of my microcontroller (do not start at the same time!). The practice can also be combinations of switches so HEX values must be literally translated output LEDs. Please help.
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Mittwoch 26. August 2015, 11:23
von IKT
lukg20 hat geschrieben:When you create macros encountered a serious problem with access.
Could you be more specific on the exact problems you've encountered?
lukg20 hat geschrieben:With RS-232 I get the value HEX 16-bit microcontroller input ATMega8.
How do you do that exactly? Are there really 2 Bytes being received?
Please post the code of the ATMega8 ... for us to 'see', what's going on there.
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Donnerstag 27. August 2015, 10:03
von lukg20
I do not have the source code Atmega.
Atmega sends the states of pins (pinc) in the form of HEX values (FF or 3F or 00 or 01 or 08 etc ....) I need to decode them into such a form that the LEDs in PROFILAB match will enter the Atmega8. When decoded hex (attachment 1 Post) into binary form LEDs light up in a different order (depending on the combination of the input states). They need to map input Atmega8.
This will be the input module in my project.
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Donnerstag 27. August 2015, 10:18
von Mike D
You have to think in hex.
$CNST2 has to be 16
$CNST1 has to be 32
Mike
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Donnerstag 27. August 2015, 10:20
von lukg20
no
Atmega8 send 8 bits.
When you check various combinations of the Windows calculator (bin this hex) results are identical.
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Donnerstag 27. August 2015, 10:43
von IKT
lukg20 hat geschrieben:Atmega8 send 8 bits.
OK, then use Byte receive (from COM) directly, similar to below:

- Byte-Input.png (33.72 KiB) 22579 mal betrachtet
HD4 is the one that is on the left hd. side of HD3 (to display the value correctly)!
Bit's 0-3 --> LOW Nibble (00-0F)
Bit's 4-7 --> HIGH Nibble(00-F0)
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Donnerstag 27. August 2015, 10:50
von lukg20
thank you very much, but it does not help me because I have to use the receiver $ string 232 with one leg

It is also used in other modules (not only input module) Could you try to solve the problem in a different way?
It seems to me that your solution also does not help.
Hex value that was converted into binary as well as at 20 and 10 to two LEDs shining at the same time.
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Donnerstag 27. August 2015, 11:19
von Mike D
I think you didn't read my post.
If you enter 10 into $CNST it will be interpreted as a decimal Number!
Mike
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Donnerstag 27. August 2015, 11:22
von IKT
You obviously don't understand:
an LED shows exactly the status of one binary line, therefore it is NORMAL that more than one LED is "lit", depending on the value you're "getting in"!
E.g. HEX - 3C means that:
- LED 1 = Off
LED 2 = Off
LED 3 = On
LED 4 = On
LED 5 = On
LED 6 = On
LED 7 = Off
LED 8 = Off
LED 1-4 (bin 0-3) = 12 decimal (HEX=C)
LED 5-8 (bin 4-7) = 3 decimal (HEX=3)
Whole range in decimal is: 0 to 255 or -128 to +127 (HEX: 00 to FF)
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Donnerstag 27. August 2015, 12:22
von lukg20
Mike D - thanks for you
I can not change what sends Atmega ...
It addresses Atmega8

pins.
When preferable to try the calculator windows in turn change his bits, 5 and 6 beating after conversion to hex you hit precisely on the values

(10; 20)
it's beyond me .... it's not for me to understand ...
Help!
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Donnerstag 27. August 2015, 13:26
von Mike D
The problem is not the Atmega program, the problem is your example "HELP ME.prj".
You simulation of the hex input is wrong.
$CNST is to make constant strings, not to make hex values. If you put 10 as string into $CNST and connect it to the anolog input of the A/D, the 10 will be interpreted as a decimal 10, and not as a hex.
Normaly you coudn't connect strings to analog, but PL has an build in auto conversion, HIGH <> 5.00, LOW <> 0.00, and numbers in strings are converted as decimal number.
Have a look at my example hex2.prj from my earlier post.
Mike
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Donnerstag 27. August 2015, 14:13
von IKT
Easy Solution: HEX (String) Input, then converted to DEC (Numeric) then converted to BIN (with A/D converter) ...
see Project below:
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Donnerstag 27. August 2015, 22:15
von lukg20
Sorry buddy Mike D. Maybe it looks like I did not pay attention to your posts.
I have a very short ProfiLab (a few days), and just teach him.
Your examples are certainly very clever, but I do not know what they have to pay attention - sorry
Back to the topic....
switches which I used in my example to serve as a simulation of what sends Atmega8 when a signal on one of the port pins C (do not know how otherwise). Thank you, buddy ICT for it that gave me a nice example, but unfortunately in this case does not work

Still the problem is not solved
As I mentioned I am building a large project all for free. In Annex I ship ready libraries (you can see how they work). I miss even libraries input modules (I have a problem with them, () and ADC - there will be no easier.
Idea: With my designs contained PCBs and diagrams can easily create each module.
The device will consist of a motherboard and modules that can be connected discretion.
For example:
6 inputs and 6 outputs, or 6 outputs and 6 ADC inputs or outputs 2x 6 (tomorrow photos of finished modules)
He promises that everything you are provided.
Please - give me an example - I am new and do not know enough PROFILAB

As I mentioned received values are the addresses of ports C.
when you use the Windows calculator can be seen as moves to 8 bits and their values in hex they correspond to those which I wrote in the example.

- Photo IO.JPG (109.16 KiB) 22418 mal betrachtet
I can not insert pictures (do not know the German language). If not so, please be moderator for help.
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Freitag 28. August 2015, 09:35
von IKT
lukg20 hat geschrieben:Thank you, buddy ICT for it that gave me a nice example, but unfortunately in this case does not work

Still the problem is not solved

I think the MAIN problem is the language here.
Your English is simply not adequate, for us to understand, what you want to tell us.
Get yourself somebody to help you with the english language, so we can understand:
what do you really want to do???
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Freitag 28. August 2015, 09:49
von lukg20
Already too much invested in this project to hire an interpreter;)
I am using "the Google translator"
Does anyone know the Polish language?
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Freitag 28. August 2015, 10:52
von IKT
Google translate (and all the others) are simply crap:
it looks like english, but it is not (english speakers don't understand it).
This is true for any language, not only english ...
Having checked your Macros (specially PortC_Out):
- 1) call it PortC_IN (from a PL point of view it is an Input)
2) use an equal amount of Macro Pin's on both sides (12 total in this case)
3) unused Inputs on components must be grounded (to work properly)
4) commenting what you're doing (helps to find faults)
5) see the modifications I've made and test it ...
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Freitag 28. August 2015, 13:25
von Mike D
Hej lukg20,
what I try to tell you is, that you think wrong in one topik.
The Atmega is sending a hex 10 (dec 16) if only bit 5 is high.
The A/D-Converter sets bit 5 high if you set hex 10 or decimal 16 to its input.
So everything is OK.
The problem is your simulation of the Atmega inputs, because you set there decimal 10 instead of hex 10.
I think you misinterpret the result shown by the windows calculator.
bin hex dec
000000 0 0
000001 1 1
000010 2 2
000100 4 4
001000 8 8
010000 10 16
100000 20 32
Mike
Re: input HEX to program LED ATMega8 - Help ME
Verfasst: Freitag 28. August 2015, 13:39
von Mike D
Oh, the solution is so easy.
please enter $10 in $CNST2
and $20 in $CNST1 then your HELP ME.projekt works fine.
The $ makes PL to interpret the values as hex.
Mike