矿石收音机论坛

 找回密码
 加入会员

QQ登录

只需一步,快速开始

搜索
查看: 3703|回复: 9

simplest (illegal!) transmitter

[复制链接]
发表于 2012-3-11 08:39:58 | 显示全部楼层 |阅读模式
here is what I put together today.

morse code transmitter.PNG

and here is the code:
  1. #include <htc.h>                                                //we use picc
  2. #include <string.h>                                                //we use strcpy
  3. #include "gpio.h"
  4. #include "config.h"                                                //configuration words
  5. #include "delay.h"                                                //software delays


  6. //hardware configuration
  7. #define RF_PORT                        GPIO
  8. #define RF_DDR                        TRISIO
  9. #define RF                                (1<<4)                        //rf out on gpio4 - do not change

  10. #define AF_PORT                        GPIO
  11. #define AF_DDR                        TRISIO
  12. #define AF                                (1<<0)                        //af out on gpio0

  13. #define BEEP_COUNT                100                                //number of beeps
  14. #define DLY_GAP                        100                                //gap, in ms
  15. #define DLY_BEEP                1                                //beep, in ms
  16. //end hardware configuration

  17. unsigned char cwRAM[17];                                //cw send buffer

  18. void beep(unsigned char n) {
  19.         while (n--) {
  20.                 IO_FLP(AF_PORT, AF);                        //flip af
  21.                 delay_ms(DLY_BEEP);
  22.         };
  23. }

  24. #define gap()                        delay_ms(DLY_GAP)
  25. //send a dot = beep + gap;
  26. //#define dot()                        {beep(BEEP_COUNT); gap();}
  27. void dot(void) {
  28.         beep(BEEP_COUNT);
  29.         gap();
  30. }

  31. //send a dash = 3 beeps + gap
  32. //#define dash()                        {beep(BEEP_COUNT); beep(BEEP_COUNT); beep(BEEP_COUNT); gap();}
  33. void dash(void) {
  34.         beep(BEEP_COUNT);
  35.         beep(BEEP_COUNT);
  36.         beep(BEEP_COUNT);
  37.         gap();
  38. }

  39. //initialize the pins
  40. void cw_init(void) {
  41.         //gp4 as output
  42.         IO_OUT(RF_DDR, RF);                                        //rf pin as output
  43.        
  44.         IO_OUT(AF_DDR, AF);                                        //af as output
  45. }

  46. //send a letter
  47. //internaltional morse code
  48. void cw_send(unsigned char dat) {
  49.         dat = (dat >= 97)? (dat - 32):dat;
  50.         switch (dat) {
  51.                 //letters
  52.                 case 'A':        dot(); dash(); break;
  53.                 case 'B':        dash(); dot(); dot(); dot(); break;
  54.                 case 'C':        dash(); dot(); dash(); dot(); break;
  55.                 case 'D':        dash(); dot(); dot(); break;
  56.                 case 'E':        dot(); break;
  57.                 case 'F':        dot(); dot(); dash(); dot(); break;
  58.                 case 'G':        dash(); dash(); dot(); break;
  59.                 case 'H':        dot(); dot(); dot(); dot(); break;
  60.                 case 'I':        dot(); dot(); break;
  61.                 case 'J':        dot(); dash(); dash(); dash(); break;
  62.                 case 'K':        dash(); dot(); dash(); break;
  63.                 case 'L':        dot(); dash(); dot(); dot(); break;
  64.                 case 'M':        dash(); dash(); break;
  65.                 case 'N':        dash(); dot(); break;
  66.                 case 'O':        dash(); dash(); dash(); break;
  67.                 case 'P':        dot(); dash(); dash(); dot(); break;
  68.                 case 'Q':        dash(); dash(); dot(); dash(); break;
  69.                 case 'R':        dot(); dash(); dot(); break;
  70.                 case 'S':        dot(); dot(); dot(); break;
  71.                 case 'T':        dash(); break;
  72.                 case 'U':        dot(); dot(); dash(); break;
  73.                 case 'V':        dot(); dot(); dot(); dash(); break;
  74.                 case 'W':        dot(); dash(); dash(); break;
  75.                 case 'X':        dash(); dot(); dot(); dash(); break;
  76.                 case 'Y':        dash(); dot(); dash(); dash(); break;
  77.                 case 'Z':        dash(); dash(); dot(); dot(); break;
  78.                 //digits
  79.                 case '1':        dot(); dash(); dash(); dash(); dash(); break;
  80.                 case '2':        dot(); dot(); dash(); dash(); dash(); break;
  81.                 case '3':        dot(); dot(); dot(); dash(); dash(); break;
  82.                 case '4':        dot(); dot(); dot(); dot(); dash(); break;
  83.                 case '5':        dot(); dot(); dot(); dot(); dot(); break;
  84.                 case '6':        dash(); dot(); dot(); dot(); dot(); break;
  85.                 case '7':        dash(); dash(); dot(); dot(); dot(); break;
  86.                 case '8':        dash(); dash(); dash(); dot(); dot(); break;
  87.                 case '9':        dash(); dash(); dash(); dash(); dot(); break;
  88.                 case '0':        dash(); dash(); dash(); dash(); dash(); break;
  89.                 default:        break; //do nothing
  90.         }
  91. }

  92. //send a string
  93. void cw_str(unsigned char * str) {
  94.         while (*str)                                                 //if str hasn't ended
  95.                 cw_send(*str++);                                        //send the current string
  96. }

  97. void mcu_init(void) {                                        //initialize the mcu
  98.         ANSEL = 0x00;                                                //porta are digital io
  99.         //ANSELH = 0x00;                                                //all portB is digital io
  100.         CMCON = 0x07;                                                //analog comparators off
  101.         //IRCF2=1, IRCF1=1, IRCF0=0;                        //running at 4Mhz

  102. }

  103. int main(void) {
  104.        
  105.         mcu_init();                                                        //initialize the mcu
  106.         cw_init();                                                        //reset cw
  107.         while (1) {
  108.                 //IO_FLP(RF_PORT, RF);
  109.                 //cw_send('A'); cw_send('B'); cw_send('C');
  110.                 strcpy(cwRAM, "Hello, world!"), cw_str(cwRAM);                //send the string
  111.         }
  112. }
复制代码
what is it?

it is a morse code transmitter working on 1Mhz.

the heart of the transmitter is a mcu (in this case, a pic12f675, 8dip). I used the internal 4Mhz rc oscillator. the oscillator is configured so that on GP4 it outputs a 1Mhz RF signal.

the audio signal is generated on GP0 - in this case, it is international morse code for "Hello, world!".

The AF signal is applied to Q1's emitter, to modulate the RF signal applied to Q1's base. the antenna is a short straight wire (4-in in length) on Q1's collector.

when I put my radio to the little transmitter, I could hear the morse code being transmitted.

This can act like a handy 1Mhz signal generator, usefully when you try to get your radio to work.

note to all: it is most likely illegal where you live to operate without a license in the AM band. but this particular transmitter is very low power - the signal dropped out ~5 meters away from the transmitter.

enjoy.

ps: the code is very portable so it should be quite easy to port  it to any mcu (either internal oscillator or crystal).

评分

1

查看全部评分

     
发表于 2012-3-11 08:56:16 | 显示全部楼层




         If al-Qaeda activists use your design,  you'll be in deep trouble.   


回复 支持 反对

使用道具 举报

     
发表于 2012-3-11 09:36:27 | 显示全部楼层
很不错的试验,不知道算不算国内的微功率

曾在哪里看过一PC软件,不增加任何硬件,就可以把一个音频文件调制发射出去,靠的是输出到显示器上特定的波形。软件有源码,可惜是Linux的,没试过,要是移植到Windows,发的是CW信号,应该不难吧
回复 支持 反对

使用道具 举报

     
发表于 2012-3-11 09:44:04 | 显示全部楼层
ace919 发表于 2012-3-10 17:36
很不错的试验,不知道算不算国内的微功率

曾在哪里看过一PC软件,不增加任何硬件,就可以把一个音频文件 ...




         对啊, 所以密级高的单位有铁笼子。
回复 支持 反对

使用道具 举报

     
发表于 2012-3-11 09:54:31 | 显示全部楼层
e3po 发表于 2012-3-11 09:44
对啊, 所以密级高的单位有铁笼子。

据说高级的笼子内自己发电,不然电源就是个泄露管道,另外下水道的口要特别处理?
回复 支持 反对

使用道具 举报

     
发表于 2012-3-11 10:04:27 | 显示全部楼层
ace919 发表于 2012-3-10 17:54
据说高级的笼子内自己发电,不然电源就是个泄露管道,另外下水道的口要特别处理?




            不知道啊。


           但是电力线的以太网适配器早就民用了,  LINKSYS, DLINK, NETGEAR 都有卖的, 20~50刀一个。
回复 支持 反对

使用道具 举报

     
发表于 2012-3-11 10:04:31 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

     
发表于 2012-3-11 10:12:44 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

发表于 2012-3-11 11:06:51 | 显示全部楼层
学习了,单片机还可以这么用,如果主频再高点的话可以发SW波段了.

As the carrier wave is square wave. If putting the audio signal (like voice) to Q1's emitter, dose an AM radio can demodulate it?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-3-12 00:04:36 | 显示全部楼层
If putting the audio signal (like voice) to Q1's emitter, dose an AM radio can demodulate it?


it does.

a simpler approach is to use the audio signal to drive the Vcc pin of a crystal oscillator (either passive or active).

that would be the simplest AM radio.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 加入会员

本版积分规则

小黑屋|手机版|矿石收音机 ( 蒙ICP备05000029号-1 )

蒙公网安备 15040402000005号

GMT+8, 2025-5-3 20:31

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表