You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- #include "config.h"
- #include "scaling.h"
- #include "util.h"
-
- uint16_t current_to_dac(float amps)
- {
- float tmp;
- uint16_t dacc;
-
- tmp = 32768 * (1 + amps / 20);
- if (tmp < 0)
- tmp = 0;
- if (tmp > 65535)
- tmp = 65535;
- dacc = (uint16_t)(tmp + 0.5);
-
- return dacc;
- }
-
- float adc12_to_current(int16_t picv)
- {
- float amps;
-
- if (picv < 0)
- picv = 0;
- if (picv > 2047)
- picv = 2047;
-
- amps = (1024.0 - picv) / 3522.6;
- return amps;
- }
|