If you are using the MIOS_AIN_PinGet() function, it returns a 10 bit value. If you put this into an 8 bit variable it will wrap around 4 times. Same thing will happen if you use the MIOS_AIN_PinLSBGet(). If this is going to be sent out as a Midi parameter, you need to use MIOS_AIN_Pin7bitGet() and it will return a value of only 0-127. MSB must be zero so it isn’t recognized as a Midi command.
As far as Dead Band, with short lines the analog converters in the PIC may still wander around a bit or more. Experiment with your Dead Band value if you need a stable value outputted.
void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam
{RANDOM = MIOS_AIN_PinGet(0);}
error 124: casting from to type 'void' is illegal
void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam
{RANDOM = MIOS_AIN_PinMSBGet(0);}
error 124: casting from to type 'void' is illegal
I have no idea what you are trying to do and why. The __wparam value is outside any defined parameter values for the function and its not part of the function which would mean it has to be beween the {}.
you ask me questions, … as NEEWBEE, i dont know what wparam and much more other stuff is, i just take TKs enviroment and change it to some Note-Processing, Velocity-Trigger-Output Device - that should trigger a TAMA TECHSTAR 306 (a analog Drumexpander)
orginally it was meend to stream the POTENTIOMETER VALUE to Midi:
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a pot has been moved
/////////////////////////////////////////////////////////////////////////////
void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam
{
// a pot has been moved, send CC#<pin-number> at channel 1
MIOS_MIDI_BeginStream();
MIOS_MIDI_TxBufferPut(0xb0); // CC at channel 1
MIOS_MIDI_TxBufferPut(pin); // pin number corresponds to CC number
MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin)); // don't send 10bit pin_value, but 7bit value
MIOS_MIDI_EndStream();
// notify display handler in DISPLAY_Tick() that AIN value has changed
last_ain_pin = pin;
app_flags.DISPLAY_UPDATE_REQ = 1;
}
I dont want stream anything to midi, I want the AIN-PIN as variable in my Program - thats all.
To get more resolution, I need 0-255 instead of 0-127
For what that Variable? > in the end to Randomly Gate the Triggerstream — Note Fall Out.
Enough Info?
so my adapted working Code is now: (of course 0-127… and not what i want 0-255)
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a pot has been moved
/////////////////////////////////////////////////////////////////////////////
void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam
{
RANDOM = MIOS_AIN_Pin7bitGet(0);
VelOff = MIOS_AIN_Pin7bitGet(1);
NOISE = MIOS_AIN_Pin7bitGet(7);
}
and I thank you for that… i was trying a lot… i was on the false Train.
You might try getting the 10 bit value then shifting it down by 2 bits. Depending on your variable types will determine how you save them. This code assumes they are 8 bit unsigned values.
unsigned int Temp;
Temp = MIOS_AIN_PinGet(0); // Get the 10 bit value.
RANDOM = (u8) (Temp >> 2); // Convert it to an 8 bit value.