I am relatively new to CAN bus, and have bought MicroMod evaluation kit. My first CAN project is converting an analogue voltage in to a CAN message. After about a day experimenting I now have now MicroMod doing this job perfectly. I would also like to convert the same input signal into a frequency (by wiring two analogue inputs together). I have got this to work, converting the analogue input first into an internal variable, then converting the internal variable into a frequency output. The output frequency goes up and down with the analogue input and the CAN output, and the scaling is correct, however the resolution of the frequency seems to be very poor. The MicroMod is set as follows:
Analogue Input number: 0
Bit position: 0
Bit length: 10
Tau: 0 (I do not understand what 'Tau' is)
PWM + Frequency Output number: 0
Byte position: 1
Bit position: 0
Bit length: 10
Timeout: 0 Hz
Powerup Value: 0 Hz
Timeout (ms): 0
The analogue input varies across the whole 0 - 5V range. The CAN output responds perfectly, but the frequency output only has about 10 steps across the whole range (0 - 10.5 Hz). I was hoping for much higher resolution than this - I expected 1024 steps (from the 10 bit input resolution) to cover the 0 - 10.5 Hz range, although I don't need resolution this high.
I have tried changing everything I can think of, but still I get very poor frequency resolution. I know the internal variable responds OK to the analogue input, because if I set it to output this value as a CAN message instead, I get all 1024 steps. I think the problem is with the internal variable to frequency conversion. Am I doing something wrong, or have I found a limitation to what the MicroMod is capable of (possibly becauae of the low frequencies involved)?
Any help would be much appreciated. Thank you
the analog input resolution are 10bit = 1024 steps -> so with a scale value 1 at the frequency output side you are able to generate frequencies in a range between 0 Hz and 1024 Hz. And with your scale factor 0.010293 it´s theoretically possible to generate frequencies between 0 Hz and 10,5 Hz. But the mimium step the hardware could handle is 1 Hz. So your 10 steps are right.
Example with output scale factor 1
0 V @ Ain = 0000h = 0 decimal x 1 = 0 Hz (theoretical) -> 0 Hz real
2.5 V @ Ain = 01ffh = 511 decimal x 1 = 511 Hz (theoretical) -> 511 Hz real
2.6 V @ Ain = 0213h = 531 decimal x1 = 531 Hz (theoretical) -> 531 Hz real
2.7 V @ Ain = 0228h = 552 decimal x 1 = 552 Hz (theoretical) -> 552 Hz real
5 V @ Ain = 03FFh = 1023 decimal x 1 = 1023 Hz (theoretical)-> 1023 Hz real
Example with output scale factor 0.01
0V @ Ain = 0000h = 0 decimal x 0.01 = 0Hz
2.5V @ Ain = 01ffh = 511 decimal x 0.01 = 5.11 Hz (theoretical) -> 5 Hz real
2.6V @ Ain = 0213h = 531 x 0.01 = 5.31 Hz (theoretical) -> 5 Hz real
2.7V @ Ain = 0228h = 552 x 0.01 = 5.52 Hz (theoretical) -> 5 Hz (or maybe 6 Hz) real
5V @ Ain = 03FFh = 1024 decimal x 0.01 = 10.23 Hz (theoretical) -> 10 Hz real
I hope this explanation helps.
Thank you for your explanation. I thought I had understood it incorrectly, so I have just done some more experimenting. My experiments seem to confirm what I initially thought - that it is not possible to get more than 10 steps across my required 0 - 10.5 Hz output fro MicroMod's frequency generator?
If I ignore offsets , and assume an input scale factor of 1, it seems like the output function for the frequency generator must be:
F out = value of Internal CAN Message * Output Scale Factor
..... so if any Output Scale Factor with a value of less than 1 is used, it also reduces the resolution of the system. In my case by a factor of 1/ 0.010293 = 97.15.
I expected the Output Scale Factor to be used to calculate the range of output frequency required, and the resolution of the Internal CAN message controlling the frequency generator would then be spread across this required frequency range, so the output resolution is the same as the input resolution.
I expected that if I wanted an output resolution of less than 10 bit, I would use an input scale factor of less than 1 to reduce the range of Internal CAN message values used to drive the frequency generator to less than 1024.
This may be an unrealistic expectation, but to someone like me who has no digital electronics background, a system where the output resolution is reduced by an output scale factor of less than 1 seems very limiting. Surely output scaling should affect the range of values that are output, not the output scaling and the output resolution?
I hope I am incorrect about this?
the output function
is right. But the hardware limits the resolution, the minimal output resolution of the Fout is 1Hz. Fout can only increased or decreased by 1 Hz (a less step is not possible)F out = value of Internal CAN Message * Output Scale Factor
For example: You define in your example a scale factor of 0.010293
-> max. Ain = 5V
-> 5V = 3ffh = 1023
-> Fout = 1023 * 0.010293 = 10,5 = 10.5 Hz
-> 10.5 Hz is the max. frequency output at 5V Ain
-> from the output side only whole-numbered frequencies are possible
So in your case it´s only possible to use the following outputs: 0/1/2/3.....8/9 and 10 Hz -> 10 steps
in your first email you wrote
and now you write something about a higher frequency....has about 10 steps across the whole range (0 - 10.5 Hz). I was hoping for much higher resolution than this - I expected 1024 steps (from the 10 bit input resolution) to cover the 0 - 10.5 Hz range, although I don't need resolution this high.
A higher resolution and a higher frequcency is not the same.