Data Comunication - rs232GUI - Signed Number
Posted: Fri Apr 04, 2008 1:29 am
Hi,
I am want to log data that from my encoder using the qei that is
sometimes negative using the TX Output Multiplexed for matlab, but
think it can only be used with signed values. Is it possible to configure the
Tx Output Multiplexed to support negative values or a modification to the block software is
necesary, and how is this achieved?
I would like to know how the data is sent to PC serial port from the dsPic so I can
may be able to interprete the data as signed unisng other matlab tools (external mode for example).
Thanks.
A. Soria.
PS. My qei version for the 30f4012
include <qei.h>
#include <p30f4012.h>
#include <ports.h>
#include "rtwtypes.h"
int ct_turns;
#define TRIS_QEA _TRISB4
#define TRIS_QEB _TRISB5
#define ENTRADA 1
#define SALIDA 0
void QEIInit(void)
{
ct_turns=0;
ADPCFG = 0xFF;
TRIS_QEA=ENTRADA;
TRIS_QEB=ENTRADA;
WriteQEI(0xFFFF);
ConfigIntQEI(QEI_INT_ENABLE & QEI_INT_PRI_3);
OpenQEI(QEI_DIR_SEL_QEB &
QEI_INPUTS_NOSWAP &
QEI_MODE_x4_MATCH,0);
POSCNT = 0;
return;
}
void __attribute__((interrupt,auto_psv)) _QEIInterrupt(void)
{
if(POSCNT==0)
ct_turns++;
if(POSCNT==0xFFFF)
ct_turns--;
_QEIIF=0;
}
int32_T GetQEI(void)
{
return (int32_T)(ct_turns*65535 +POSCNT);
}
I am want to log data that from my encoder using the qei that is
sometimes negative using the TX Output Multiplexed for matlab, but
think it can only be used with signed values. Is it possible to configure the
Tx Output Multiplexed to support negative values or a modification to the block software is
necesary, and how is this achieved?
I would like to know how the data is sent to PC serial port from the dsPic so I can
may be able to interprete the data as signed unisng other matlab tools (external mode for example).
Thanks.
A. Soria.
PS. My qei version for the 30f4012
include <qei.h>
#include <p30f4012.h>
#include <ports.h>
#include "rtwtypes.h"
int ct_turns;
#define TRIS_QEA _TRISB4
#define TRIS_QEB _TRISB5
#define ENTRADA 1
#define SALIDA 0
void QEIInit(void)
{
ct_turns=0;
ADPCFG = 0xFF;
TRIS_QEA=ENTRADA;
TRIS_QEB=ENTRADA;
WriteQEI(0xFFFF);
ConfigIntQEI(QEI_INT_ENABLE & QEI_INT_PRI_3);
OpenQEI(QEI_DIR_SEL_QEB &
QEI_INPUTS_NOSWAP &
QEI_MODE_x4_MATCH,0);
POSCNT = 0;
return;
}
void __attribute__((interrupt,auto_psv)) _QEIInterrupt(void)
{
if(POSCNT==0)
ct_turns++;
if(POSCNT==0xFFFF)
ct_turns--;
_QEIIF=0;
}
int32_T GetQEI(void)
{
return (int32_T)(ct_turns*65535 +POSCNT);
}