Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - integer value change

(you are viewing a thread; or go back to list of threads)

integer value change (by Kelvin)
Hi,

Can anyone help me. For my counting application i need 0-65535. So is there any possibility to change the integer value. As we're all knew, that ldmicro handles only signed integer (-32768 ... 32767). So is it possible to change. Anyone's help will be highly appreciated. Thanks.


Kelvin
Tue Apr 16 2013, 00:59:29
(no subject) (by Kelvin)
Ok forgot to let you know guys. FYI I need this integer value change option, because i'm currently doing a project, which
counts digital inputs & display the counted value via a serial LCD. The counted value will be maximum up to 50000. So, it will be easy for me to handle the value if the counting value starts from 0-65535.


Regards,

Kelvin
Tue Apr 16 2013, 01:59:55
(no subject) (by Ziggy)
In a way of an answer a question follows:

Could You possibly set up a units counter to count from 0-9 and then increment another counter which would count in lots of tens. This way you would be counting up to 32767 lots of tens in one counter and 0 to 9 units in another counter.

The net effect is You would be counting from 0 to 327679 which is more than You need.

You would take care of display by formatting the output string to accommodate the place values ( units 0-9 and tens 0-32767 ).

Critical in all of this is the way you format and concatenate strings in Your display routine and hopefully do not introduce "off by one" in Your counting algorithm.
Tue Apr 16 2013, 10:05:19
(no subject) (by Kelvin)
Hi ziggy,

Thanks for the suggestion. OK actually i'm thinking about having a comparator for example 50000. The counted digital inputs value will always compare with this comparator. When the counts reached 50000 or more, it will trigger an output port for Alarm purpose.
So, based on your suggestion i can just make the counting like in lots on tens. But for handling comparison value how?.

That's why i'm looking for where it will be nice and easy if the Ldmicro can also handle unsigned integer. I can simply insert the value and do the comparison.

Regards,

Kelvin
Tue Apr 16 2013, 20:19:11
(no subject) (by Ziggy)
If counting 50000 items is the issue then preload two counters with 0 value.
Use one to count up to the limit and use its output state to enable the second counter to count up to 50000 - 32767 = 17233

When the second counter reaches 17233 You have the trigger for alarm.
A simpler solution if ALARM only is required.

I have not tried this but may be You should just do an experiment and preload a counter with 0 and see how far it counts up.
Then preload it with -32768 and count up and see how far it goes.

You can set up an oscilator with reasonable frequency ( inside LD micro and feed that into the counter for experimental purpose under simulator and see outcomes.
Tue Apr 16 2013, 21:51:26
(no subject) (by Kelvin)
Hi ziggy. it seems your suggestion is ok for Alarming section.

But i've tried and i found the program is going too complex if i want to save the counted value & also the comparator value in EEPROM and at the same time print out the counter or comparator value to LCD.

Regards,


Kelvin
Wed Apr 17 2013, 02:10:01
(no subject) (by Ziggy)
Program too complex or too large for the micro controller You wish to use?
By the by what are You using?
Wed Apr 17 2013, 07:40:19
(no subject) (by Kelvin)

i'm using 16F88
Wed Apr 17 2013, 20:00:40
(no subject) (by Kelvin)

Ok is there any other way to make ldmicro handles unsigned integer like modifying it's source code?. Anyone please advice.

Thanks,


Kelvin
Thu Apr 18 2013, 19:57:54
(no subject) (by Ziggy)
I might be able to help..if it were an AVR micro.
Fri Apr 19 2013, 16:48:18
(no subject) (by Kelvin)
Hi ziggy,

As what you've mentioned above, could you able to modify the source code so it can handle unsigned integer, if the device is AVR?. Unfortunately i don't use AVR. Could you able to try something so it can also be possible on PIC?. Your help/ assistance will be highly appreciated.

Thanks.



Kelvin.
Tue Apr 23 2013, 20:25:05
(no subject) (by Ziggy)
Hello Kelvin,

In case of AVR one can outptu C file.

C file calls for additional processing to get it to a sensible collection of code to be able to compile it ( from C to hex which will run on the micro.)

So the proposal is to generate C code and then additional header files and the modify signed int to unsigned int.

If You have a C compiler for PIC You may be able to implement a set of header files to achieve this outcome.

For a aste of how its done on AVR see

http://electronics4dogs.blogsp...11/07/ldmicro-and-arduino.html
Wed Apr 24 2013, 20:04:13
(no subject) (by Kelvin)

Hi Ziggy,

I saw the example. Actually i don't have any other compiler than LDmicro. FYI I'm a person with Automation background, which mostly deals with the PLC & ladder programs. This is my first project using PIC. So compilers like C is new to me & never been used before. OK i will try my level best with your above suggestion and refer with you if anything.

Thanks.


Regards,

Kelvin
Thu Apr 25 2013, 02:16:49
(no subject) (by charly)
Can you share the code that you use to output the number.
how many counter you need, what math op do you do on that number. Just some question for deciding if extending ldmicro
or not.
Sun Apr 28 2013, 12:45:25
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):