I was not sure if it would work or not, but I thought that it should because a constant is a constant. That was actually pretty lazy of me, I guess I could have just done a debug with it. But thanks anyhow.
With respect to You.
If You have only debugged it That will be only info for You.
As You posted it NOW even Beginners have good insight how it can be done.
I was not sure if it would work or not, but I thought that it should because a constant is a constant. That was actually pretty lazy of me, I guess I could have just done a debug with it. But thanks anyhow.
You can even do calculations in the constant definition. The advantage of doing this is, that the calculation is done during compile-time and not during run-time. For example:
CON
INPUT_MASK = |<1
PUB main
dira := INPUT_MASK
outa |= INPUT_MASK
waitcnt( clkfreq + cnt )
outa &= ! |< 1
Another way of doing pre-calculations during compile-time is using constant()
outa &= constant( ! |<1 )
This is actual code from a program that reads the voltage from the tap of a divider that uses a 14.7K and 1.62K resistor. The MCP3208 is running at 5v (5_000) and has 12 bits (4_095) of resolution. The divider allows the circuit to know what the input voltage is which could be 12 or 24 volts, and to measure it specifically in case the motors it's running start demanding more current than the supply can handle.
Note that this is a test program and I would suggest using named constants; I will ultimately change this code to use named constants -- something like this:
That sounds very impressive. How does that compare to other A/D converters?
Honestly, I don't know -- you'd have to look at the specs for other ADCs under consideration. I wrote a PASM driver for the above project which lets me pass the address of an array of my choice to it and the array is updated every millisecond which is more than fast enough for my application. My PASM object allows me to set the update rate so I could go faster since the chip and PASM would support it.
The MCP32xx is an easy chip to use and you can find more than one file in ObEx (including an very easy-to-use Spin version) from me. I also used that family in this project for Nuts & Volts.
Never mind. I found the answer to that question. I definitely have a whole lot more respect for you now. Very very impressive. I have referred to your work on countless occasions.
Comments
-Phil
I was not sure if it would work or not, but I thought that it should because a constant is a constant. That was actually pretty lazy of me, I guess I could have just done a debug with it. But thanks anyhow.
Bruce
With respect to You.
If You have only debugged it That will be only info for You.
As You posted it NOW even Beginners have good insight how it can be done.
I agree 100%!
Bruce
Another way of doing pre-calculations during compile-time is using constant()
outa &= constant( ! |<1 )
That was a very good tip! I liked that. I have done calculations in the constant definition but
I never thought about the calcuations continuing on through the program.
Bruce
This is actual code from a program that reads the voltage from the tap of a divider that uses a 14.7K and 1.62K resistor. The MCP3208 is running at 5v (5_000) and has 12 bits (4_095) of resolution. The divider allows the circuit to know what the input voltage is which could be 12 or 24 volts, and to measure it specifically in case the motors it's running start demanding more current than the supply can handle.
Note that this is a test program and I would suggest using named constants; I will ultimately change this code to use named constants -- something like this:
I just looked at the MCP3208 datasheet, at it says That sounds very impressive. How does that compare to other A/D converters?
And thanks for the tip Jon
Bruce
Honestly, I don't know -- you'd have to look at the specs for other ADCs under consideration. I wrote a PASM driver for the above project which lets me pass the address of an array of my choice to it and the array is updated every millisecond which is more than fast enough for my application. My PASM object allows me to set the update rate so I could go faster since the chip and PASM would support it.
The MCP32xx is an easy chip to use and you can find more than one file in ObEx (including an very easy-to-use Spin version) from me. I also used that family in this project for Nuts & Volts.
http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp8.pdf
Okay, I can be gullible, I'll bite, is Jon Williams your pen name? Are you that Jon?
Bruce
Never mind. I found the answer to that question. I definitely have a whole lot more respect for you now. Very very impressive. I have referred to your work on countless occasions.
Bruce