Hi Eveeryone
I am looking for Programming for SAMPLING two 12 BITS CHANNELS AT 500 Hz in Dynamic C using RCM 3700.
Dynamic C includes a bunch of samples in the RCM3700/ADC folder for sampling analog channels. What have you been able to get working, and what are you currently stuck on? Can you read a single 12-bit channel? Is it the sampling frequency that’s an issue? Storage of samples?
Thanks for reply. Let recheck one more time. within two days I will get back to u. Below program I wrote.
#class auto
#define DS1 0x40 //led, port F bit 6 bitmask
#define DS2 0x80 //led, port F bit 7 bitmask
/***********************************
- Configuration Section *
- --------------------- *
- All fields in this section must *
- be altered to match your local *
- network settings. *
**********************************/
/ - Pick the predefined TCP/IP configuration for this sample. See
- LIB\TCPIP\TCP_CONFIG.LIB for instructions on how to set the
- configuration.
/
#define TCPCONFIG 1
#define _PRIMARY_STATIC_IP “192.168.0.40”
#define _PRIMARY_NETMASK “255.255.255.0”
#ifndef MY_NAMESERVER
#define MY_NAMESERVER “10.10.6.1”
#endif
#ifndef MY_GATEWAY
#define MY_GATEWAY “192.168.0.1”
#endif
/ - TCP/IP modification - reduce TCP socket buffer
- size, to allow more connections. This can be increased,
- with increased performance, if the number of sockets
- are reduced. Note that this buffer size is split in
- two for TCP sockets–1024 bytes for send and 1024 bytes
- for receive.
*/
#define TCP_BUF_SIZE 2048
/*
- Web server configuration
*/
/*
- Define the number of HTTP servers and socket buffers.
- With tcp_reserveport(), fewer HTTP servers are needed.
*/
#define HTTP_MAXSERVERS 2
#define MAX_TCP_SOCKET_BUFFERS 2
/*
- Our web server as seen from the clients.
- This should be the address that the clients (netscape/IE)
- use to access your server. Usually, this is your IP address.
- If you are behind a firewall, though, it might be a port on
- the proxy, that will be forwarded to the Rabbit board. The
- commented out line is an example of such a situation.
*/
#define REDIRECTHOST _PRIMARY_STATIC_IP
// #define REDIRECTHOST “my.host.com:8080”
/********************************
- End of configuration section *
********************************/
/*
- REDIRECTTO is used by each ledxtoggle cgi’s to tell the
- browser which page to hit next. The default REDIRECTTO
- assumes that you are serving a page that does not have
- any address translation applied to it.
*/
#define REDIRECTTO “http://” REDIRECTHOST “/index.shtml”
#memmap xmem
#use “dcrtcp.lib”
#use “http.lib”
/*
- Notice that we have ximported in the source code for
- this program. This allows us to
- in the pages/showsrc.shtml.
*/
#ximport “samples/rcm3700/tcpip/pages/browseled.shtml” index_html
#ximport “samples/rcm3700/tcpip/pages/rabbit1.gif” rabbit1_gif
#ximport “samples/rcm3700/tcpip/pages/led1on.gif” led1on_gif
#ximport “samples/rcm3700/tcpip/pages/led1off.gif” led1off_gif
#ximport “samples/rcm3700/tcpip/pages/led2on.gif” led2on_gif
#ximport “samples/rcm3700/tcpip/pages/led2off.gif” led2off_gif
#ximport “samples/rcm3700/tcpip/pages/button.gif” button_gif
#ximport “samples/rcm3700/tcpip/pages/showsrc.shtml” showsrc_shtml
#ximport “samples/rcm3700/tcpip/browseled.c” browseled_c
/*
- In this case the .html is not the first type in the
- type table. This causes the default (no extension)
- to assume the shtml_handler.
*/
/* the default for / must be first */
SSPEC_MIMETABLE_START
SSPEC_MIME_FUNC(“.shtml”, “text/html”, shtml_handler),
SSPEC_MIME(“.html”, “text/html”),
SSPEC_MIME(“.gif”, “image/gif”),
SSPEC_MIME(“.cgi”, “”)
SSPEC_MIMETABLE_END
/*
- Each ledx contains a text string that is either
- “ledon.gif” or “ledoff.gif” This string is toggled
- each time the ledxtoggle.cgi is requested from the
- browser.
*/
char led1[15];
char led2[15];
int led1toggle(HttpState* state)
{
if (strcmp(led1,“led1on.gif”)==0)
strcpy(led1,“led1off.gif”);
else
strcpy(led1,“led1on.gif”);
cgi_redirectto(state,REDIRECTTO);
return 0;
}
int led2toggle(HttpState* state)
{
if (strcmp(led2,“led2on.gif”)==0)
strcpy(led2,“led2off.gif”);
else
strcpy(led2,“led2on.gif”);
cgi_redirectto(state,REDIRECTTO);
return 0;
}
SSPEC_RESOURCETABLE_START
SSPEC_RESOURCE_XMEMFILE(“/”, index_html),
SSPEC_RESOURCE_XMEMFILE(“/index.shtml”, index_html),
SSPEC_RESOURCE_XMEMFILE(“/showsrc.shtml”, showsrc_shtml),
SSPEC_RESOURCE_XMEMFILE(“/rabbit1.gif”, rabbit1_gif),
SSPEC_RESOURCE_XMEMFILE(“/led1on.gif”, led1on_gif),
SSPEC_RESOURCE_XMEMFILE(“/led1off.gif”, led1off_gif),
SSPEC_RESOURCE_XMEMFILE(“/led2on.gif”, led2on_gif),
SSPEC_RESOURCE_XMEMFILE(“/led2off.gif”, led2off_gif),
SSPEC_RESOURCE_XMEMFILE(“/button.gif”, button_gif),
SSPEC_RESOURCE_XMEMFILE(“browseled.c”, browseled_c),
SSPEC_RESOURCE_ROOTVAR(“led1”, led1, PTR16, “%s”),
SSPEC_RESOURCE_ROOTVAR(“led2”, led2, PTR16, “%s”),
SSPEC_RESOURCE_FUNCTION(“/led1tog.cgi”, led1toggle),
SSPEC_RESOURCE_FUNCTION(“/led2tog.cgi”, led2toggle),
SSPEC_RESOURCETABLE_END
void update_outputs()
{
auto int value;
value=PFDRShadow&0x3F; //on state for leds
/* update O0 */
costate
{
BitWrPortI(PBDR, &PBDRShadow, 0, 5); // chip select low
sent [1]=160; // channel 0
for(j = 0;j < 10;j++);
SPIWrRd(sent,received, 3);
for(j = 0;j < 10;j++);
BitWrPortI(PBDR, &PBDRShadow, 1, 5); // chip select high
i=(received[1]%16)*256+received [2];
printf("ADC 0value: %d ", i);
serDputc(received[1]%16);
serDputc(received[2]);
BitWrPortI(PBDR, &PBDRShadow, 0, 5); // chip select low
sent [1]=224; //channnel 1
for(j = 0;j < 10;j++);
SPIWrRd(sent,received, 3);
for(j = 0;j < 10;j++);
BitWrPortI(PBDR, &PBDRShadow, 1, 5); // chip select high
i=(received[1]%16)*256+received [2];
printf("ADC 0value: %d ", i);
serDputc(received[1]%16);
serDputc(received[2]);
waitfor(DelayMs(2));
/* update O1 */
}
costate
{ if (strcmp(led2,“led2on.gif”))
// value|=DS2;
BitWrPortI(PADR, &PADRShadow,1, 4); //PA6=0
else BitWrPortI(PADR, &PADRShadow,0, 4); //PA6=0
WrPortI(PFDR, &PFDRShadow, value);
}
}
main()
{
//brdInit(); //initialize board for this demo
WrPortI(SPCR,&SPCRShadow,0x84); //PortA outputs
BitWrPortI(PBDR, &PBDRShadow,0, 6); //PA6=0
BitWrPortI(PBDR, &PADRShadow,0, 4); //PA6=0
strcpy(led1,“led1on.gif”);
strcpy(led2,“led2off.gif”);
sock_init();
http_init();
tcp_reserveport(80);
while (1)
{
update_outputs();
http_handler();
}
}
#nodebug