Jump to content

cviewengineer

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About cviewengineer

  • Rank
    Newbrie
  1. Thanks to both of you...the data type for ydata is a signed char. Excellent suggestion Orin, thank you...I did end up going to an unsigned char for various other reasons, but I will be using a form of the algorithm you posted. Regards,
  2. I have a bunch of the following type statements: if(ydata >= -128 && ydata < -107){ y_delay = 2; y_dir = 0; y_stop = 0; } if(ydata > -108 && ydata < -81){ y_delay = 7; y_dir = 0; y_stop = 0; } if(ydata > -82 && ydata < -55){ y_delay = 13; y_dir = 0; y_stop = 0; } I don't want to execute unnecessary code, i.e. once the correct range for ydata is found, it should disregard the remainder of the if statements. I realize that I could return from a function, or a few other things, but what I need is an elsif statement. It seems that sourceboost used to support this statement but not anymore...is this correct? Time is extremely critical...but I'd still rather not write it in .asm. I just need to not execute every statement. Any ideas? Thank you for your time.
  3. thanks for the reply...i'm using a 16F887, but i found the problem it wasn't triggering on the voltage i wanted, and i finally figured out it was triggering on 0.6V...which is the fixed ref i wasn't setting the proper bits in the cm2con1 register...i'm using comparator 1 so i just skipped over it thinking that its just a register for comparator 2, well it has 1 bit in it that controls comparator 1, that's what i missed Regards, -Aaron
  4. I'm trying to get the comparator to work...I can get the ADC to work using pin RA0, and know I'm trying to get the comparator to work for that pin...my dev board has a pot connected to that pin. Here is my code for the comparator: #include <system.h> #pragma CLOCK_FREQ 18432000 #pragma DATA _CONFIG1, 0b0010001111110011 void main(){ //RA0 is the pot connection trisa = 0x01; ansel = 0x01; cm1con0 = 0b11010100; vrcon = 0b11101111; trisd = 0x00; //configure port B portd = 0x00; //clear port B while(1){ portd.0 = 1; delay_ms(500); portd.0 = 0; delay_ms(500); if(cm1con0.6 == 1){ portd.7 = 1; delay_ms(500); portd.7 = 0; delay_ms(500); portd.7 = 1; delay_ms(500); portd.7 = 0; delay_ms(500); } } } portd is connected to LED's, so the first output to it are just to let me know the code is running, and the second out is for seeing if the compare feature is working...which it isn't if I haven't provided enough information please let me know any help is greatly appreciated
×
×
  • Create New...