Detecting SCAB

SHG

New member
Is there a way to detect if a SCAB is attached? Many of the command codes only work if a SCAB is present, and so I'd like my library to do a check when it's instantiated, and then those items that require a SCAB can throw an exception if one's not available.
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

CF Tech

Administrator
All of the commands work if a SCAB is there or not, they just will have no effect if no SCAB is there.

Since the SCAB has a 1K pull-up on GPIO[4] (the DOW line) it should be possible to use that to detect if it is connected:

1) set GPIO[4] to drive high, pull low
2) drive it low (meaning it is pulled low by the internal 5K)
3) read it

If it is low, then no SCAB is attached, if it is high (1K SCAB pull-up swamping internal 5K pull-down) then a SCAB is attached.

4) restore GPIO[4]'s port state.
 

SHG

New member
I don't understand

I'm sorry, but I'm not understanding exactly what you mean to do with the GPIO. I'm guessing you're wanting me to send command 34. Can you specify what the packet values are please?
 

CF Tech

Administrator
Actually it will be a combination of some 34's and 35's.

Let me try it out and I'll post back here with the commands & results.
 

CF Support

Administrator
You can try this code here:
Code:
void DetectSCAB()
{
	COMMAND_PACKET GPIO_State_returned;
	GPIO_State_returned.command=0;
	
	COMMAND_PACKET command_to_module;
	command_to_module.command=0;

	// set to drive high, pull low
	command_to_module.command=34;
	command_to_module.data[0]=4;
	command_to_module.data[1]=0;
	command_to_module.data[2]=8;
	command_to_module.data_length=3;
	send_packet(&command_to_module);

	command_to_module.command=35;
	command_to_module.data[0]=4;
	command_to_module.data_length=1;
	send_packet(&command_to_module);

	command_to_module.command=35;
	command_to_module.data[0]=4;
	command_to_module.data_length=1;
	send_packet(&command_to_module);

	command_to_module.command=35;
	command_to_module.data[0]=4;
	command_to_module.data_length=1;
	send_packet(&command_to_module);


	fprintf(stdout,"Detecting SCAB\n");

	int retries=0;
	while(retries<=3)
	{
		if(check_for_packet(&GPIO_State_returned))
		{
			ShowReceivedPacket(&GPIO_State_returned);
			if(GPIO_State_returned.command==0x63)
			{
				if((GPIO_State_returned.data[0]==4)&&(GPIO_State_returned.data[1]==0))
				{
					fprintf(stdout,"No SCAB Detected\n");
					retries++;
				}
				else if((GPIO_State_returned.data[0]==4)&&(GPIO_State_returned.data[1]>0))
				{
					fprintf(stdout,"SCAB Detected\n");
					command_to_module.command=34;
					command_to_module.data[0]=4;
					command_to_module.data[1]=0;
					command_to_module.data[2]=7;
					command_to_module.data_length=3;
					send_packet(&command_to_module);
					return;
				}
			}
		}
		else
			check_for_packet(&GPIO_State_returned);
		if((retries==3)&&(((GPIO_State_returned.data[0]==4)&&(GPIO_State_returned.data[1]==0))))
		{
			fprintf(stdout,"No SCAB Detected after 3 retries.\n");
			exit(1);
		}
		Sleep(10);
	}	
	return;
}
It will produce something along these lines:

 
Top