Exemplo n.º 1
0
main()
{
	double Pot,LastSpeed_X=0.0,LastSpeed_Y=0.0,LastSpeed_Z=0.0;
	
	printf("%f\n",KANALOG_CONVERT_ADC_TO_VOLTS(ADC(0)));
	
	for (;;)
	{
		T1=WaitNextTimeSlice();

		if (T1-T0 > 0.05)  // only change speed every so often
		{
			// convert 0-10V input to -1.0 to 1.0 range
			// Pot mid range of 5V will be zero
			Pot=KANALOG_CONVERT_ADC_TO_VOLTS(ADC(0)) * (1.0/5.0) - 1.0;
			
			// force small values to exactly zero (stopped)
			if (Pot < MIN_THRESHOLD && Pot > -MIN_THRESHOLD) Pot=0;

			DoSpeedAxis(XAXIS, XSELECT, &LastSpeed_X, Pot*MAX_SPEED_X);
			DoSpeedAxis(YAXIS, YSELECT, &LastSpeed_Y, Pot*MAX_SPEED_Y);
			DoSpeedAxis(ZAXIS, ZSELECT, &LastSpeed_Z, Pot*MAX_SPEED_Z);
		}
	}
}
Exemplo n.º 2
0
void sleep_task(void) {
    static uint8_t sleep_flag = 0;
    if (ADC(POWER_SW) < 2048) {
        sleep_flag = 1;
        INTCONbits.GIE = 0;
        for (uint8_t i = 0; i < NUM_PORT; i++) {
            OUT(i, 0);
            LED_output(i, 0);
        }
        I2C_LCD_Clear();
        I2C_LCD_SetCursor(0, 0);
        I2C_LCD_Puts("Charge Station 6");
        I2C_LCD_SetCursor(0, 1);
        I2C_LCD_Puts("SLEEPING NOW");
    }
    while (sleep_flag) {
        if (ADC(POWER_SW) > 2048) {
            sleep_flag = 0;
            display(LOGO, "Charge Station", "Welcome back!");
            break;
        }
        SLEEP();
        NOP();
    }
}
Exemplo n.º 3
0
mp_limb_t	divexact_submul(mp_ptr qp,mp_ptr xp,mp_size_t n)
{int j;mp_limb_t c,m,t1,t2,t3,acc,ax,dx,t;

ASSERT(n>0);ASSERT_MPN(xp,n);ASSERT(MPN_SAME_OR_SEPARATE_P(qp,xp,n));
m=0;m=~m;m=m/3;// m=(B-1)/3
c=0;t1=t2=t3=acc=0;
    umul_ppmm(dx,ax,xp[0],m);
    SUB(c,acc,0,t1);
    ADC(c,t2,0,ax,c);
    ADC(c,t3,0,dx,c);
    ASSERT(c==0);
    t1=t2;t2=t3;
for(j=1;j<=n-1;j++)
   {
    t3=0;
    umul_ppmm(dx,ax,xp[j],m);
    SUB(c,acc,acc,t1);
    qp[j-1]=acc;
    ADC(c,t2,t2,ax,c);
    ADC(c,t3,t3,dx,c);
    ASSERT(c==0);
    t1=t2;t2=t3;
   }
    SUB(c,acc,acc,t1);
    qp[n-1]=acc;
    ADC(c,t2,t2,0,c);
    t=(t2-acc)*3;
// return next quotient*-3    
return t;}   // so  (xp,n) = (qp,n)*3 -ret*B^n    and 0 <= ret < 3
Exemplo n.º 4
0
/*ADC A,#*/
static void op_0xce(Z80EX_CONTEXT *cpu)
{
	temp_byte=READ_OP();
	ADC(A,temp_byte);
	T_WAIT_UNTIL(7);
	return;
}
Exemplo n.º 5
0
void Apu88()
{
   // ADC A,#00
   uint8 Work8 = OP1;
   ADC(IAPU.YA.B.A, Work8);
   IAPU.PC += 2;
}
Exemplo n.º 6
0
void Apu94()
{
   // ADC A,dp+X
   uint8 Work8 = S9xAPUGetByteZ(OP1 + IAPU.X);
   ADC(IAPU.YA.B.A, Work8);
   IAPU.PC += 2;
}
Exemplo n.º 7
0
void Apu84()
{
   // ADC A,dp
   uint8 Work8 = S9xAPUGetByteZ(OP1);
   ADC(IAPU.YA.B.A, Work8);
   IAPU.PC += 2;
}
Exemplo n.º 8
0
/*ADC A,(HL)*/
static void op_0x8e(Z80EX_CONTEXT *cpu)
{
	READ_MEM(temp_byte,(HL),4);
	ADC(A,temp_byte);
	T_WAIT_UNTIL(7);
	return;
}
Exemplo n.º 9
0
void Apu86()
{
   // ADC A,(X)
   uint8 Work8 = S9xAPUGetByteZ(IAPU.X);
   ADC(IAPU.YA.B.A, Work8);
   IAPU.PC++;
}
Exemplo n.º 10
0
void Apu88()
{
   // ADC A,#00
   uint8_t Work8 = OP1;
   ADC(IAPU.Registers.YA.B.A, Work8);
   IAPU.PC += 2;
}
Exemplo n.º 11
0
void Apu86()
{
   // ADC A,(X)
   uint8_t Work8 = S9xAPUGetByteZ(IAPU.Registers.X);
   ADC(IAPU.Registers.YA.B.A, Work8);
   IAPU.PC++;
}
Exemplo n.º 12
0
void Apu94()
{
   // ADC A,dp+X
   uint8_t Work8 = S9xAPUGetByteZ(OP1 + IAPU.Registers.X);
   ADC(IAPU.Registers.YA.B.A, Work8);
   IAPU.PC += 2;
}
Exemplo n.º 13
0
Arquivo: pu-test.c Projeto: gke/UAVP
void AnalogTest(void)
{
	int32 v;

	TxString("\r\nAnalog ch. test\r\n");

	// Battery
	v = ((int24)ADC(ADCBattVoltsChan, ADCVREF5V) * 46 + 9)/17; // resolution is 0,01 Volt
	TxVal32(ADCBattVoltsChan, 0, ' ');
	TxString("Batt:\t");
	TxVal32(v, 2, 'V');
	if ( v < 900 )
		TxString(" ** LIPO ALARM < 9V ** ");
	else	
	if ( v < 950 )
		TxString(" ** LOW < 9.5V ** ");
	TxNextLine();

	// Pitch
	v = ((int24)ADC(ADCPitchChan, ADCVREF5V) * 49 + 5)/10; // resolution is 0,001 Volt
	TxVal32(ADCPitchChan, 0, ' ');
	TxString("Pitch:\t");		
	TxVal32(v, 3, 'V');	
	TxNextLine();

	// Roll
	v = ((int24)ADC(ADCRollChan, ADCVREF5V) * 49 + 5)/10; // resolution is 0,001 Volt
	TxVal32(ADCRollChan, 0, ' ');
	TxString("Roll: \t"); 
	TxVal32(v, 3, 'V'); 
	TxNextLine();

	// VRef
	v = ((int24)ADC(ADCVRefChan, ADCVREF5V) * 49 + 5)/10; // resolution is 0,001 Volt
	TxVal32(ADCVRefChan, 0, ' ');	
	TxString("Ref:  \t");	
	TxVal32(v, 3, 'V');	
	TxNextLine();

	// Yaw
	v = ((int24)ADC(ADCYawChan, ADCVREF5V) * 49 + 5)/10; // resolution is 0,001 Volt
	TxVal32(ADCYawChan, 0, ' ');
	TxString("Yaw:  \t");
	TxVal32(v, 3, 'V');	
	TxNextLine();

} // AnalogTest
Exemplo n.º 14
0
void Apu97()
{
   // ADC A, (dp)+Y
   IndirectIndexedY();
   uint8 Work8 = S9xAPUGetByte(((IAPU.Address)));
   ADC(IAPU.YA.B.A, Work8);
   IAPU.PC += 2;
}
Exemplo n.º 15
0
void Apu96()
{
   // ADC A, abs+Y
   AbsoluteY();
   uint8 Work8 = S9xAPUGetByte(((IAPU.Address)));
   ADC(IAPU.YA.B.A, Work8);
   IAPU.PC += 3;
}
Exemplo n.º 16
0
void Apu87()
{
   // ADC A,(dp+X)
   IndexedXIndirect();
   uint8 Work8 = S9xAPUGetByte(((IAPU.Address)));
   ADC(IAPU.YA.B.A, Work8);
   IAPU.PC += 2;
}
Exemplo n.º 17
0
void Apu97()
{
   // ADC A, (dp)+Y
   IndirectIndexedY();
   uint8_t Work8 = S9xAPUGetByte(IAPU.Address);
   ADC(IAPU.Registers.YA.B.A, Work8);
   IAPU.PC += 2;
}
Exemplo n.º 18
0
void Apu87()
{
   // ADC A,(dp+X)
   IndexedXIndirect();
   uint8_t Work8 = S9xAPUGetByte(IAPU.Address);
   ADC(IAPU.Registers.YA.B.A, Work8);
   IAPU.PC += 2;
}
Exemplo n.º 19
0
void Apu96()
{
   // ADC A, abs+Y
   AbsoluteY();
   uint8_t Work8 = S9xAPUGetByte(IAPU.Address);
   ADC(IAPU.Registers.YA.B.A, Work8);
   IAPU.PC += 3;
}
Exemplo n.º 20
0
void Apu99()
{
   // ADC (X),(Y)
   uint8_t W1 = S9xAPUGetByteZ(IAPU.Registers.X);
   uint8_t Work8 = S9xAPUGetByteZ(IAPU.Registers.YA.B.Y);
   ADC(W1, Work8);
   S9xAPUSetByteZ(W1, IAPU.Registers.X);
   IAPU.PC++;
}
Exemplo n.º 21
0
void Apu89()
{
   // ADC dp(dest),dp(src)
   uint8_t Work8 = S9xAPUGetByteZ(OP1);
   uint8_t W1 = S9xAPUGetByteZ(OP2);
   ADC(W1, Work8);
   S9xAPUSetByteZ(W1, OP2);
   IAPU.PC += 3;
}
Exemplo n.º 22
0
void Apu98()
{
   // ADC dp,#00
   uint8_t Work8 = OP1;
   uint8_t W1 = S9xAPUGetByteZ(OP2);
   ADC(W1, Work8);
   S9xAPUSetByteZ(W1, OP2);
   IAPU.PC += 3;
}
Exemplo n.º 23
0
/*ADC A,(IX+$)*/
static void op_DD_0x8e(Z80EX_CONTEXT *cpu)
{
	temp_byte=READ_OP();
	temp_byte_s=(temp_byte & 0x80)? -(((~temp_byte) & 0x7f)+1): temp_byte;
	MEMPTR=(IX+temp_byte_s);
	READ_MEM(temp_byte,(IX+temp_byte_s),12);
	ADC(A,temp_byte);
	T_WAIT_UNTIL(15);
	return;
}
Exemplo n.º 24
0
Arquivo: 6510.c Projeto: trieck/source
/*
 * add with carry immediate mode
 */
void _adcImm(void)
{
    byte value;

    value = fetch_byte((word)(cpu.pc + 1));

    ADC(value);

    cpu.pc += 2;
}
Exemplo n.º 25
0
Arquivo: 6510.c Projeto: trieck/source
/*
 * add with carry zero page mode
 */
void _adcZp(void)
{
    byte zaddr, value;

    zaddr = fetch_byte((word)(cpu.pc + 1));
    value = fetch_byte(zaddr);
    ADC(value);

    cpu.pc += 2;
}
Exemplo n.º 26
0
Arquivo: 6510.c Projeto: trieck/source
/*
 * add with carry, absolute mode
 */
void _adcAbsl(void)
{
    word addr;
    byte value;
    addr = fetch_word((word)(cpu.pc + 1));
    value = fetch_byte(addr);

    ADC(value);

    cpu.pc += 3;
}
Exemplo n.º 27
0
Arquivo: 6510.c Projeto: trieck/source
/*
 * add with carry absolute, y mode
 */
void _adcAby(void)
{
    word addr;
    byte value;
    addr = fetch_word((word)(cpu.pc + 1));
    addr += cpu.y;

    value = fetch_byte(addr);
    ADC(addr);

    cpu.pc += 3;
}
Exemplo n.º 28
0
main ()
{
	P1DIR = 3;
	CLKCON = 0;
	while (!(SLEEP & SLEEP_XOSC_STB))
		;

	adc_init();
	P1_0 = 1;
	usart_init();
	for (;;) {
		adc_run();
		usart_out_string("accel: ");
		usart_out_number(ADC(0));
		usart_out_string(" pres: ");
		usart_out_number(ADC(1));
		usart_out_string(" temp: ");
		usart_out_number(ADC(2));
		usart_out_string(" batt: ");
		usart_out_number(ADC(3));
		usart_out_string(" drogue: ");
		usart_out_number(ADC(4));
		usart_out_string(" main: ");
		usart_out_number(ADC(5));
		usart_out_string("\r\n");
		delay(10);
	}
}
Exemplo n.º 29
0
Arquivo: 6510.c Projeto: trieck/source
/*
 * add with carry indirect, y mode
 */
void _adcIdy(void)
{
    byte zaddr, value;
    word addr;

    zaddr = fetch_byte((word)(cpu.pc + 1));

    addr = fetch_word(zaddr) + cpu.y;
    value = fetch_byte(addr);
    ADC(value);

    cpu.pc += 2;
}
Exemplo n.º 30
0
void Auto_cut(void) {
    for (uint8_t i = 0; i < NUM_PORT; i++) {
        // ADC sampling
        port[i].current = 13 * ADC(ANALOG_IN(i)) / 16; // *13/16
        if (port[i].flag.auto_cut_ON) {
            if (port[i].current < CUT_CURRENT) { //もし一定電流を下回ったらカウントアップスタート
                port[i].cut_cnt++;
                if (port[i].cut_cnt > CUT_TIME) { //一定時間たったら、出力シャットアウト
                    OUT(i, 0);
                }
            } else { //経過時間カウントリセット
                port[i].cut_cnt = 0;
            }
        }
    }
}