Page 1 of 1

xScope No Probes

Posted: Tue Feb 19, 2013 5:15 pm
by dimitris
Hello community. It's my first post. Nice to meet you.

I am working on a slice kit with 12.1.0 tools.
I got a pretty simple design however the xScope denies to probe stuff.
-added the Xmos Link in the .xn file
-added the -fxscope flag on the makefile
-XTAG2 Link is set to on
-one slice kit
-one gpio module

I post my code in case somebody wants to dive in.
Thanx in advance!

EDIT: My xScope is permanently disconnected and when in offline mode the output file is always empty.

Code: Select all

#include<xs1.h>
#include<print.h>
#include "i2c.h"
#include<platform.h>
#include<string.h>
#include <math.h>
#include"common.h"
#include <xscope.h>


#define I2C_NO_REGISTER_ADDRESS 1
#define debounce_time XS1_TIMER_HZ/50
#define print_delay 5000000
#define BUTTON_PRESS_VALUE 2


#define epsilon 0.01
#define dt 0.01			//100ms loop time
#define MAX 4			//For current stauration
#define MIN -4
#define Kp 0.1
#define Kd 0.005
#define Ki 0.01

/*---------------------------------------------------------------------------
 ports and clocks
 ---------------------------------------------------------------------------*/
 //::Port configuration

on stdcore[1]: port p_PORT_BUT_1=XS1_PORT_4C;
on stdcore[1]: struct r_i2c i2cOne = {
		XS1_PORT_1F,
		XS1_PORT_1B,
		1000
 };

void xscope_user_init(void) {
  xscope_register(2,
    XSCOPE_CONTINUOUS, "Microphone Left",  XSCOPE_FLOAT, "mVL",
    XSCOPE_CONTINUOUS, "Microphone Right", XSCOPE_FLOAT, "mVR"
  );
}


int gpio(chanend setpoint_TX){
	unsigned button_press_1,button_press_2,time_gpio;
	int button=1;
	float setpoint=2750.0;
	timer t_gpio;

	p_PORT_BUT_1:> button_press_1;
	set_port_drive_low(p_PORT_BUT_1);

	t_gpio:>time_gpio;

	while(1){
		setpoint_TX <: setpoint;
		//printstr("Setpoint: ");
		//printintln(setpoint);
	}
}

void sense( chanend sense_TX){
	//ADC init register value
//0 0 0 0 0 0 1 1				NO CHANNEL
	//unsigned char data[1]={0x03};
//0 0 0 1 0 0 1 1				1st CHANNEL
	//unsigned char data[1]={0x13};
//0 0 1 0 0 0 1 1				2nd CHANNEL
	unsigned char data[1]={0x23};
//0 1 0 0 0 0 1 1				3rd CHANNEL
	//unsigned char data[1]={0x43};
//1 0 0 0 0 0 1 1				4th CHANNEL
	//unsigned char data[1]={0x83};
//0 0 1 1 0 0 1 1				1st & 2nd CHANNEL
//	unsigned char data[1]={0x33};

	unsigned time_sense;
	timer t_sense;
	unsigned char temp[2];
	float adc_value;

////::Write config
	i2c_master_write_reg(0x28, 0x00, data, 1, i2cOne); //Write configuration information to ADC
	t_sense :> time_sense;
	while(1){
		temp[0]=0;temp[1]=0;
		i2c_master_rx(0x28, temp, 2, i2cOne); //Read ADC value using I2C read
		adc_value=(temp[0]<<6)|(temp[1]>>2);
		sense_TX <: adc_value;
	}
}

float PIDcall(float setpoint, float actualpoint){
	static float pre_error = 0;
	static float integral = 0;
	float error;
	float derivative;
	float output;

		//Calculate P,I,D
		error = setpoint - actualpoint;

		//in case of error too small then stop integration
		if(fabs(error)>epsilon){
			integral = integral + error*dt;
		}
		derivative = (error -pre_error)/dt;
		output = Kp*error + Ki*integral + Kd*derivative;

		//Update Error
		pre_error = error;
		return output;
}


void control(chanend setpoint_TX, chanend sense_TX){
	float output, setpoint, actualpoint,temppoint,diff;
	unsigned time_control;
	timer t_control;

	t_control :> time_control;

	while(1){

		sense_TX :> actualpoint;
		setpoint_TX :> setpoint;
		temppoint=1102;

		do{
			temppoint = PIDcall(setpoint,temppoint);
			diff = setpoint-temppoint;
			xscope_probe_data(0, temppoint);
			xscope_probe_data(1, diff);
		}while(fabs(diff)>epsilon);
	}
}


/**
 * Top level main for multi-UART demonstration
 */
 //::Main start
int main(void)
{
	chan setpoint_TX, sense_TX;

	par
	{
		on stdcore[1]: sense(sense_TX);
		on stdcore[1]: gpio(setpoint_TX);
		on stdcore[1]: control(setpoint_TX, sense_TX);
	}

	return 0;
}

//::Main

Re: xScope No Probes

Posted: Tue Feb 19, 2013 5:44 pm
by sethu_jangala
Hi Dimitris,

You can find the xscope examples in the following repository:

https://github.com/xcore/sw_xscope_examples

Thanks,
Sethu.

Re: xScope No Probes

Posted: Tue Feb 19, 2013 6:17 pm
by dimitris
Sethu,
thank you for the response. I have used those examples but I also haven't managed to get probes on the xscope. To be honest I went through them but I mostly based on the xscope documentation to avoid incompatibilities.

Re: xScope No Probes

Posted: Tue Feb 19, 2013 7:46 pm
by Folknology
Also make sure X0D3-6 on star slice socket are not connected/used.

regards
Al

Re: xScope No Probes

Posted: Tue Feb 19, 2013 10:26 pm
by dimitris
Dear Folknology,

nothing is being used apart from the GPIO on the square slot.
I tried all the sw_example apps too and still the xScope has the red Disconnected label...

Re: xScope No Probes

Posted: Wed Feb 20, 2013 5:10 am
by sethu_jangala
Dimitris,

Is the Link Switch "ON" on the XA-SK-XATG2(Xtag2 adapter slice)[black color switch]. If this is "OFF", this should be made "ON" to use Xscopes.

Also, while running from the xtimecomposer, have you enabled xscope in "Run Configurations" menu.

Thanks,
Sethu.

Re: xScope No Probes

Posted: Wed Feb 20, 2013 10:04 am
by dimitris
Hi Sethu,

Yes the link is ON as well as the xScope in Run Configurations. I have also tried both offline and real time modes but still nothing. The xScope starts but it looks as disconnected.