Browse Source

Introduced usage of full 20 bits of PWM period counter

git-svn-id: https://bucket.mit.edu/svn/nilm/acquisition/ethstream@7286 ddd99763-3ecb-0310-9145-efcb8ce7c51f
tags/ethstream-1.1
zacharyc 15 years ago
parent
commit
357e808986
3 changed files with 20 additions and 12 deletions
  1. +9
    -6
      ethstream.c
  2. +10
    -5
      nerdjack.c
  3. +1
    -1
      nerdjack.h

+ 9
- 6
ethstream.c View File

@@ -65,7 +65,7 @@ struct options opt[] = {
int doStream(const char *address, uint8_t scanconfig, uint16_t scaninterval,
int *channel_list, int channel_count, int convert, int maxlines);
int nerdDoStream(const char *address, int *channel_list, int channel_count, int precision,
unsigned short period, int convert, int lines, int showmem);
unsigned long period, int convert, int lines, int showmem);
int data_callback(int channels, uint16_t *data, void *context);

int columns_left = 0;
@@ -104,7 +104,7 @@ int main(int argc, char *argv[])
int nerdjack = 0;
int detect = 0;
int precision = 0;
int period = NERDJACK_CLOCK_RATE / desired_rate;
unsigned long period = NERDJACK_CLOCK_RATE / desired_rate;

/* Parse arguments */
opt_init(&optind);
@@ -277,20 +277,23 @@ int main(int argc, char *argv[])
if (nerdjack_choose_scan(desired_rate, &actual_rate, &period) < 0) {
info("error: can't achieve requested scan rate (%lf Hz)\n",
desired_rate);
return 1;
//return 1;
}
} else {
if (ue9_choose_scan(desired_rate, &actual_rate,
&scanconfig, &scaninterval) < 0) {
info("error: can't achieve requested scan rate (%lf Hz)\n",
desired_rate);
return 1;
//return 1;
}
}

if ((desired_rate != actual_rate) || verb_count)
if ((desired_rate != actual_rate) || verb_count){
info("Actual scanrate is %lf Hz\n", actual_rate);
info("Period is %ld\n",period);
}

if (verb_count && lines) {
info("Stopping capture after %d lines\n", lines);
@@ -354,7 +357,7 @@ int main(int argc, char *argv[])
}

int nerdDoStream(const char *address, int *channel_list, int channel_count, int precision,
unsigned short period, int convert, int lines, int showmem)
unsigned long period, int convert, int lines, int showmem)
{
int retval = -EAGAIN;
int fd_data;


+ 10
- 5
nerdjack.c View File

@@ -45,16 +45,21 @@ typedef struct __attribute__((__packed__)) {

/* Choose the best ScanConfig and ScanInterval parameters for the
desired scanrate. Returns -1 if no valid config found */
int nerdjack_choose_scan(double desired_rate, double *actual_rate, int *period)
int nerdjack_choose_scan(double desired_rate, double *actual_rate, unsigned long *period)
{
*period = floor((double) NERDJACK_CLOCK_RATE / desired_rate);
if(*period > UINT16_MAX) {
//The +1 corrects a silicon bug. The timer resets to 1, not 0.
*period = floor((double) NERDJACK_CLOCK_RATE / desired_rate) + 1;
if(*period > 0x0fffff) {
info("Cannot sample that slowly\n");
*actual_rate = (double)NERDJACK_CLOCK_RATE / (double) 0x0ffffe;
//info("Sampling at slowest rate:%f\n",*actual_rate);
return -1;
}
*actual_rate = (double) NERDJACK_CLOCK_RATE / (double) *period;
//Period holds the period register for the NerdJack, so it needs to be right
*actual_rate = (double) NERDJACK_CLOCK_RATE / (double) (*period - 1);
if(*actual_rate != desired_rate) {
//info("Sampling at nearest rate:%f\n",*actual_rate);
return -1;
}
return 0;


+ 1
- 1
nerdjack.h View File

@@ -51,6 +51,6 @@ int nerdjack_detect(char * ipAddress);

/* Choose the best ScanConfig and ScanInterval parameters for the
desired scanrate. Returns -1 if no valid config found */
int nerdjack_choose_scan(double desired_rate, double *actual_rate, int *period);
int nerdjack_choose_scan(double desired_rate, double *actual_rate, unsigned long *period);

#endif

Loading…
Cancel
Save