| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			jgschmidt
 
 
  Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA 
			
			 
			 
			 
			 
			
			
			
			
			
  
		  | 
		
			
				| PIC16F1825 Data Signal Modulator - UPDATED see below | 
			 
			
				 Posted: Tue Apr 16, 2013 5:47 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Hi,
 
 
I need to do some 38KHz carrier IR signalling and was bemoaning the need for another part just to AND the carrier and data. However, I was re-reading the data sheet for the PIC16F1825/1829 part and noticed the Data Signal Modulator (DSM) (Section 23), so perhaps not anymore...
 
 
I checked my CCS (PCWHD 4.135) help file and found a DSM section in the functional overviews. However, there is no page in the manual for the referenced setup_dsm() function. 
 
 
So my questions are:
 
 
1) does anyone know where to find the detailed documentation for setup_dsm()?
 
 
2) I'm no EE and don't totally understand the data sheet - is the DSM suitable for sending serial data via IR? I'd then like to receive it via a typical 38khz IR receiver connected to the RX pin of another PIC. My hardwired connection works fine but I ultimately can not have a physical connection.  My transmission distance is on the order of centimeters.
 
 
3) Does anyone who may have done this have any recommendations? (fastest data rate, recommended DSM settings, etc.)
 
 
Thanks in advance for any help. _________________ Jürgen
 
www.jgscraft.com
  Last edited by jgschmidt on Wed Apr 17, 2013 1:46 pm; edited 1 time in total | 
			 
		  | 
	
	
		  | 
	
	
		
			dyeatman
 
 
  Joined: 06 Sep 2003 Posts: 1968 Location: Norman, OK 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue Apr 16, 2013 6:09 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Setup_dsm is covered in the PCD manual, page 63, and includes a pretty 
 
good description of how it works (not as good as the data sheet though).
 
All the usage is also covered.  Looks like OOK might be what you need.
 
 
 	  | Quote: | 	 		  The Data Signal Modulator (DSM) allows the user to mix a digital 
 
data stream (the “modulator signal”) with a carrier signal to produce a 
 
modulated output. Both the carrier and the modulator signals are supplied
 
to the DSM module, either internally from the output of a peripheral, or
 
externally through an input pin.
 
 
The modulated output signal is generated by performing a logical AND
 
operation of both the carrier and modulator signals and then it is provided
 
to the MDOUT pin.
 
 
Using this method, the DSM can generate the following types of key modulation schemes:
 
 
- Frequency Shift Keying (FSK)
 
- Phase Shift Keying (PSK)
 
- On-Off Keying (OOK)
 
 | 	 
  _________________ Google and Forum Search are some of your best tools!!!! | 
			 
		  | 
	
	
		  | 
	
	
		
			jgschmidt
 
 
  Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA 
			
			 
			 
			 
			 
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue Apr 16, 2013 8:47 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Thanks, that helps a little.
 
 
Looks like I'm out of luck, however, because I get "Unidentified identifier -- setup_dsm" when I try to use the function with the 16F1825.
 
 
When I check the Devices files there are  6 24FJxGAx devices that have DSM_ entries. 
 
 
Sigh! 
 
 
In my searching I came across the following:
 
 
http://www.rentron.com/Micro-Bot/IR_Serial.htm
 
 
which is a pretty sneaky solution! I'll give that a try.
 
 
Cheers, _________________ Jürgen
 
www.jgscraft.com | 
			 
		  | 
	
	
		  | 
	
	
		
			dyeatman
 
 
  Joined: 06 Sep 2003 Posts: 1968 Location: Norman, OK 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				| Setup_dsm() | 
			 
			
				 Posted: Tue Apr 16, 2013 9:01 pm     | 
				     | 
			 
			
				
  | 
			 
			
				You don't have to use the setup_dsm().  You can access the registers 
 
directly.  It  looks pretty straightforward.   If I had one of them I would
 
give it a shot.  I'll get one on order to play with. _________________ Google and Forum Search are some of your best tools!!!! | 
			 
		  | 
	
	
		  | 
	
	
		
			jgschmidt
 
 
  Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA 
			
			 
			 
			 
			 
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Apr 17, 2013 8:43 am     | 
				     | 
			 
			
				
  | 
			 
			
				Oops! Duh! Forgot about that. Thanks for the reminder. I'll set up my #bytes and #bits and see how it goes.
 
 
Cheers, _________________ Jürgen
 
www.jgscraft.com | 
			 
		  | 
	
	
		  | 
	
	
		
			jgschmidt
 
 
  Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA 
			
			 
			 
			 
			 
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Apr 17, 2013 1:52 pm     | 
				     | 
			 
			
				
  | 
			 
			
				For anyone interested here is some sample code that successfully demonstrates the Data Signal Modulator ( DSM ) of the PIC16F1825. 
 
 
 	  | Code: | 	 		  
 
#case
 
// 1825DSMTest.c  Data Signal Modulation Test
 
//
 
// 16F1825/1829 
 
// - All ports support internal weak pullups
 
// - 25mA sink/source on I/O pins
 
//
 
// Target:        
 
// Hardware:     
 
// Compiler:      CCS PCWH 4.135
 
// Programmer:    PICkit2
 
// Dependencies:  None
 
//
 
// 2013.04.17 - Jurgen G Schmidt www.jgscraft.com
 
//
 
//    + VDD - 1   14 - VSS -
 
// OSC1/RA5 - 2   13 - RA0/DAT
 
// OSC2/RA4 - 3   12 - RA1/CLK
 
// MCLR/RA3 - 4   11 - RA2/CCP3
 
// CCP1/RC5 - 5   10 - RC0/SCL/SCK
 
//   TX/RC4 - 6    9 - RC1/SDA/SDI/CCP4 
 
// CCP2/RC3 - 7    8 - RC2/    SDO
 
//
 
//-----------------------------------------------------------------------------
 
#include <16f1825.h>
 
 
#FUSES INTRC_IO      //Internal RC Osc, no output
 
#FUSES NOWDT         //No Watch Dog Timer
 
#FUSES NOPUT         //No Power Up Timer
 
#FUSES NOMCLR        //Engages weak pullup
 
#FUSES NOBROWNOUT    //No brownout reset
 
//#FUSES CLKOUT        //Check FOSC/4 on pin 3 - should be .125us
 
 
#use delay(internal=32M)
 
 
//-----------------------------------------------------------------------------
 
//------ DSM Register Definitions
 
 
#byte MDCON    = 0x39C     //--Modulation control register--
 
#bit  MDEN     = MDCON.7      // DSM Enable 1=on
 
#bit  MDOE     = MDCON.6      // MDOUT Pin enable 1=on
 
#bit  MDSLR    = MDCON.5      // slew rate limiting enabled 1=on
 
#bit  MDOPOL   = MDCON.4      // output polarity 1=signal is inverted
 
#bit  MDOUT    = MDCON.3      // current value of MDOUT pin
 
#bit  MDBIT    = MDCON.0      // 1= Modulator uses high carrier source
 
 
#byte MDSRC    = 0x39D     //--Modulation source control register--
 
#bit  MDMSODIS = MDSRC.7      // 1= disable output signal driving peripheral out pin
 
#bit  MDMS3    = MDSRC.3      // Modulation source 
 
#bit  MDMS2    = MDSRC.2      // 0000 = MDBIT of MDCON
 
#bit  MDMS1    = MDSRC.1      // 0001 = MDMIN port pin
 
#bit  MDMS0    = MDSRC.0      // 1010 = EUSART TX output
 
 
#byte MDCARH   = 0x39F     //--Modulation high carrier control register--
 
#bit  MDCHODIS = MDCARH.7     // 1= disable output signal driving peripheral out pin
 
#bit  MDCHPOL  = MDCARH.6     // output polarity 1=signal is inverted
 
#bit  MDCHSYNC = MDCARH.5     // Modulator high carrier synchronization 1=on
 
#bit  MDCH3    = MDCARH.3     // Data high carrier selection bits
 
#bit  MDCH2    = MDCARH.2     // 0000 = Vss
 
#bit  MDCH1    = MDCARH.1     // 0100 = CCP1
 
#bit  MDCH0    = MDCARH.0     // 0001 = MDCIN1 port pin (C2 / pin 8)
 
                              // set to: 10100100
 
 
#byte MDCARL   = 0x39E     //--Modulation low carrier control register--
 
#bit  MDCLODIS = MDCARL.7     // 1= disable output signal driving peripheral out pin
 
#bit  MDCLPOL  = MDCARL.6     // output polarity 1=signal is inverted
 
#bit  MDCLSYNC = MDCARL.5     // Modulator low carrier synchronization 1=on
 
#bit  MDCL3    = MDCARL.3     // Data low carrier selection bits
 
#bit  MDCL2    = MDCARL.2     // 0000 = Vss
 
#bit  MDCL1    = MDCARL.1     // 0100 = CCP1
 
#bit  MDCL0    = MDCARL.0     // 0001 = MDCIN1 port pin (C2 / pin 8)
 
                              // set to: 0b10100000
 
 
// Test 1 - use MDMIN pin (pin 7) to toggle carrier output on MDOUT (pin 6)  WORKS!!!!!
 
// 
 
// MDCON  = 0b11000001;    // DSM enable, MDOUT enable, no slew, not inverted, modulator uses high carrier source
 
// MDSRC  = 0b10000001;    // disable peripheral, data from MDMIN pin (so we can see triggering on OSCOPE)
 
// MDCARH = 0b10100100;    // disable peripheral, not inverted, synced, data high = CCP1 (38khz carrier)
 
// MDCARL = 0b10100000;    // disable peripheral, not inverted, synced, data low = Vss
 
//
 
 
//-----------------------------------------------------------------------------
 
 
void main()
 
{
 
   setup_adc_ports( NO_ANALOGS); 
 
 
   setup_timer_2(T2_DIV_BY_1, 210, 1 );            
 
   setup_ccp1( CCP_PWM );            
 
   set_pwm1_duty( 422L );       // 38khz square wave output - 50% duty            
 
 
   MDCON  = 0b11000001;    // DSM enable, MDOUT enable, no slew, not inverted, modulator uses high carrier source
 
   MDSRC  = 0b10000001;    // disable peripheral, data from MDMIN pin (so we can see triggering on OSCOPE)
 
   MDCARH = 0b10100100;    // disable peripheral, not inverted, synced, data high = CCP1 (38khz carrier)
 
   MDCARL = 0b10100000;    // disable peripheral, not inverted, synced, data low = Vss
 
 
   
 
   //------ Big Loop ------
 
   while( TRUE )
 
   {
 
      delay_ms( 1 );
 
      output_toggle( PIN_C0 );   // generate signal for oscilloscope to measure loop time
 
   }//------ end of big loop
 
}
 
//-----------------------------------------------------------------------------
 
//------ end of 1825DSMTest.c ------ | 	  
 
 
Happy coding! _________________ Jürgen
 
www.jgscraft.com | 
			 
		  | 
	
	
		  | 
	
	
		
			dyeatman
 
 
  Joined: 06 Sep 2003 Posts: 1968 Location: Norman, OK 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Apr 17, 2013 3:41 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Outstanding! Great job!
 
 
How about adding a version of this to the code library? _________________ Google and Forum Search are some of your best tools!!!! | 
			 
		  | 
	
	
		  | 
	
	
		
			jgschmidt
 
 
  Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA 
			
			 
			 
			 
			 
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Apr 17, 2013 5:05 pm     | 
				     | 
			 
			
				
  | 
			 
			
				I intend to. I want to verify some of the other features, particularly the UART connection. Coming soon... _________________ Jürgen
 
www.jgscraft.com | 
			 
		  | 
	
	
		  | 
	
	
		
			dyeatman
 
 
  Joined: 06 Sep 2003 Posts: 1968 Location: Norman, OK 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Sat Apr 20, 2013 4:03 pm     | 
				     | 
			 
			
				
  | 
			 
			
				JGScmidt,
 
CCS support just replied with the following:
 
 	  | Quote: | 	 		  We currently only have built-in functions for the DSM module in the 
 
PCD compiler.  We are planning on adding support for it to the PCM and PCH 
 
compiler in the next few weeks. 
 
 | 	 
  _________________ Google and Forum Search are some of your best tools!!!! | 
			 
		  | 
	
	
		  | 
	
	
		
			asmboy
 
 
  Joined: 20 Nov 2007 Posts: 2128 Location: albany ny 
			
			 
			 
			
			
			 
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Sun Apr 21, 2013 9:12 am     | 
				     | 
			 
			
				
  | 
			 
			
				now ifMicrochip had a data DEMODULATOR integrated for NRZ signals
 
THAT would be a real accompishment 
 
 
 
and lots of cheap 433 mhz data connect systems could be better supported too | 
			 
		  | 
	
	
		  | 
	
	
		
			jgschmidt
 
 
  Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA 
			
			 
			 
			 
			 
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Fri Apr 26, 2013 8:30 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Thanks, dyeatman, for finding that. Working with the CCS compiler for 15 years I know how quickly that can actually happen.
 
 
IR send/receive code using the DSM has been posted in the library.
 
 
I'd like to know what other chips have the DSM but unfortunately Microchip does not list this feature in their part finder. (Sigh)
 
 
My thanks to anyone who adds part numbers having the DSM to this post.
 
 
Cheers, _________________ Jürgen
 
www.jgscraft.com | 
			 
		  | 
	
	
		  | 
	
	
		
			PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Fri Apr 26, 2013 8:44 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Do a Google search for this:
 
 	  | Quote: | 	 		  | site:microchip.com -forums "data signal modulator" "data sheet"  type:pdf | 	 
  | 
			 
		  | 
	
	
		  | 
	
	
		
			jgschmidt
 
 
  Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA 
			
			 
			 
			 
			 
			
			
			
			
			
  
		  | 
		
			
				| PICs with DSM (Data Signal Modulator) | 
			 
			
				 Posted: Sat Apr 27, 2013 10:16 am     | 
				     | 
			 
			
				
  | 
			 
			
				Thanks. That added one more to the list, which now stands at:
 
12F18xx and 16F18xx
 
18LFxxK80
 
18F97J94 family
 
24FJ64/128GA306/308/310 <- supported by PCD 4.135  _________________ Jürgen
 
www.jgscraft.com | 
			 
		  | 
	
	
		  | 
	
	
		
			Gabriel
 
 
  Joined: 03 Aug 2009 Posts: 1074 Location: Panama 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue Apr 30, 2013 7:28 am     | 
				     | 
			 
			
				
  | 
			 
			
				I was having the same problem of having to add an extra part....
 
 
i never got to test my solution, but i thought of using the comparator module as an AND gate..... 
 
 
you would still need a few resistors but thats easier than adding a whole 14 pin AND gate chip or transistors...
 
 
.. i know its late in the thread but someone might find it useful...
 
 
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 | 
			 
		  | 
	
	
		  | 
	
	
		 |