Jump to content

AIN unmuxed 0 255 0 255 overroll


Phatline
 Share

Recommended Posts

8Bit 18f452 Core - SDCC -10K Pot direct connected to J5, rest  to GND

 

the Pot give me 4times 0-255 on his travel way (0-255, 0-255, 0-255, 0-255)

 

in main.c i got this settings:

//Include files
#include <cmios.h>
#include <pic18fregs.h>
#include "main.h"

void Init(void) __wparam
{
  MIOS_AIN_NumberSet(7);
  MIOS_AIN_UnMuxed();
  //MIOS_AIN_DeadbandSet(10);

What I tried:

removing "MIOS_AIN_DeadbandSet(0);"

typing "MIOS_AIN_DeadbandSet(7);" "MIOS_AIN_DeadbandSet(14);" "MIOS_AIN_DeadbandSet(0);" "MIOS_AIN_DeadbandSet(1);"

 

also tried this variant of main.c

 

Question is:

what Parameter definies this 4x0-255?

 

Is it right that i dont need the deadband set, when i use unmuxed, and short wires?!

Edited by Phatline
Link to comment
Share on other sites

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.

Edited by kpete
Link to comment
Share on other sites

THANKS - SOLVED --- @ the End i have a other Question, what if i want to have 0-255 instead of 0-127?

Your Tip - work: (RANDOM = VARIABLE)

void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam
{if(pin == 0) {RANDOM = MIOS_AIN_Pin7bitGet(0);}

0-127

 

ahhh, dont need filtering by pin:

void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam
{RANDOM = MIOS_AIN_Pin7bitGet(0);}

0-127

 

 

-----------------------------------------------------what not work---------------------------------------------------------------

void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam
{if(pin == 0) {RANDOM = pin_value;}
0-255 0-255 0-255 0-255

 

void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam
{RANDOM = MIOS_AIN_PinGet(0);}
0-255 0-255 0-255 0-255

 

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
Edited by Phatline
Link to comment
Share on other sites

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)

 

TK has written this: http://ucapps.de/mios/ain64_din128_dout128_v2c.zip

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.

Edited by Phatline
Link to comment
Share on other sites

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.

Temp = MIOS_AIN_PinGet(1);   

VelOff = (u8) (Temp >> 2);   

Temp = MIOS_AIN_PinGet(7);   

NOISE = (u8) (Temp >> 2);   

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...