佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

楼主: ^Hins86^

家电中央无线遥控器系统[完成了,感谢所有帮过我的人]

  [复制链接]
 楼主| 发表于 1-11-2009 09:51 PM | 显示全部楼层
这个是我读了很多关于visual basic 的例子组合起来和modify 的(红色和蓝色)
但我只弄到这里不知道怎样继续了
请问版主能提点一下吗
回复

使用道具 举报


ADVERTISEMENT

发表于 3-11-2009 11:30 AM | 显示全部楼层
原帖由 ^Hins86^ 于 31-10-2009 09:51 AM 发表


哇。。76面
看来有排看了
lol....


那只是一份而已。
你先了解miwi wireless protocol还有p2p。看哪一个适合你。
然后解释解释下。
现在你应该有能力分析,到底哪一个适合你。看你解释过后, 我才进入programming part.
这是为了确定你对miwi有一定的了解程度, 我才深入一点讲。 当然我也不是pro.
有问题可以上来发问。
回复

使用道具 举报

发表于 3-11-2009 11:32 AM | 显示全部楼层
原帖由 ^Hins86^ 于 1-11-2009 09:51 PM 发表
这个是我读了很多关于visual basic 的例子组合起来和modify 的(红色和蓝色)
但我只弄到这里不知道怎样继续了
请问版主能提点一下吗


怎么会有serialport1.turnonlight(1)?
serialport1是serialport object吗?还是你其他的class inherit serial port class?
回复

使用道具 举报

 楼主| 发表于 3-11-2009 06:33 PM | 显示全部楼层
原帖由 fritlizt 于 3-11-2009 11:30 AM 发表


那只是一份而已。
你先了解miwi wireless protocol还有p2p。看哪一个适合你。
然后解释解释下。
现在你应该有能力分析,到底哪一个适合你。看你解释过后, 我才进入programming part.
这是为了确定你对m ...


ok... 还在了解着
miwi wireless protocol还有p2p 加起来有76面。。lol
p2p 我读到差不多一半了
miwi wireless protocol 看一些了
我发觉miwi wireless protocol 好像有一点比p2p 的 application note 难懂
等我看完p2p 才看miwi wireless protocol
哈哈
回复

使用道具 举报

 楼主| 发表于 3-11-2009 06:44 PM | 显示全部楼层
原帖由 fritlizt 于 3-11-2009 11:32 AM 发表


怎么会有serialport1.turnonlight(1)?
serialport1是serialport object吗?还是你其他的class inherit serial port class?

serialport1是serialport object
其实serialport1.turnonlight(1) 我觉得应该改成serialport1.write(    ,    ,   )
不知道对不对
可是不知道里面要怎样写
format 我读到的是 SerialPort.Write(Byte[ ], Int32, Int32)
或 serialport.Write(buffer, offset, count)
可是就是不了解要怎样写
还有不知道这个方法对吗
基本上我写给button 的code 是 button 显示 ON (in off state)
然后 OFF( in on state)
其它的就是要写来send signal 给pic 来inteprete on/off light 1/light 2 了
回复

使用道具 举报

 楼主| 发表于 4-11-2009 12:18 AM | 显示全部楼层
最新update...不知道对不对


[ 本帖最后由 ^Hins86^ 于 5-11-2009 11:06 PM 编辑 ]
回复

使用道具 举报

Follow Us
 楼主| 发表于 5-11-2009 11:09 PM | 显示全部楼层
刚刚读完p2p 的application note
我想问下
像我要控制两个receiver
我到底是用什么method 来给receiver 知道我现在是要send signal 给receiver 1/receiver 2
是用不同的channel吗?(我想知道它的keyword 是什么)


[ 本帖最后由 ^Hins86^ 于 6-11-2009 08:54 AM 编辑 ]
回复

使用道具 举报

 楼主| 发表于 12-11-2009 08:11 PM | 显示全部楼层
版主最近不的空吗?
我大致上看完了p2p 和networking 的application note 了
我分不清有什么分别wor
我只知道supported topology 不同而已
haiz....
然后transmit 和receive 的我发现只不过是send 不同的id 来分辨而已
对吗?就像我放红箭头的地方
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 16-11-2009 10:59 PM | 显示全部楼层
fritlizt ,我想问下到底怎样写哦
之前你叫我看的p2p node 1 demo pic18 的
我看到里面的header file 有这么多样东西
是不是那些全部我都要用到的呢
我到底要program 些什么进我的pic 呢
我需要在下星期之前弄完le...
haiz....
回复

使用道具 举报

发表于 17-11-2009 09:18 AM | 显示全部楼层
原帖由 ^Hins86^ 于 16-11-2009 10:59 PM 发表
fritlizt ,我想问下到底怎样写哦
之前你叫我看的p2p node 1 demo pic18 的
我看到里面的header file 有这么多样东西
是不是那些全部我都要用到的呢
我到底要program 些什么进我的pic 呢
我需要在下星期之前弄完 ...

从简单开始。用p2p node1 simple example开始。

先加hardware profile.让这个protocol stack可以support你的circuit board.
你只要search active project , keyword:" PICDEMZ ",你就可以看到4个result.

C:\Microchip Solutions\P2P\P2P Node 1\HardwareProfile.c:149:     #if defined(PICDEMZ)
C:\Microchip Solutions\P2P\P2P Node 1\SimpleExampleNode1.c:190:     #if defined(PICDEMZ) || defined(PIC18_EXPLORER)
C:\Microchip Solutions\P2P\P2P Node 1\HardwareProfile.h:59:     //#define PICDEMZ
C:\Microchip Solutions\P2P\P2P Node 1\HardwareProfile.h:179:     #if defined(PICDEMZ)

在picdemz附近,加入你的hardware profile即可。
原因我迟点再解释。
还有一个地方要改的就是configuration bit.你用的是25k20, 你看hardware profile.c的上面,有ifdef _18f4620, _pic18f2520 blabla bla 等等的东西。 看你如何设计你的circuit和怎样用,自行config.

所以你总共有五个地方要改。b4你进入programming.

先讲config bit.
给你hints.我的config bit 是
internal oscillator. ra6,7 as i/o
fail safe clock disable
Oscillator Switchover mode disabled
Brown-out Reset enabled and controlled by software (SBOREN is enabled)
VBOR set to 2.7 V nominal
WDT is controlled by SWDTEN bit of the WDTCON register
RE3 input pin enabled; MCLR disabled
The system clock is held off until the HF-INTOSC is stable
PORTB<4:0> pins are configured as digital I/O on Reset
CCP2 input/output is multiplexed with RB3
Single-Supply ICSP disabled
Background debugger enabled, RB6 and RB7 are dedicated to In-Circuit Debug

很多是不需要的,我只是看着config bit user manual写的时候, 顺便写下去。

接下来hardware profile.h里面的 //#define PICDEMZ
你会看到picdemz被comment掉。 因为default example是explorer 18
你要自己define 自己的board.可以是MY_BOARD或者其他, 名字你自己定

to be continue.......
回复

使用道具 举报

 楼主| 发表于 17-11-2009 05:28 PM | 显示全部楼层
原帖由 fritlizt 于 17-11-2009 09:18 AM 发表

从简单开始。用p2p node1 simple example开始。

先加hardware profile.让这个protocol stack可以support你的circuit board.
你只要search active project , keyword:" PICDEMZ ",你就可以看到4个result.

C: ...


我不了解是要怎样加hardware profile..还有什么circuit board 的
我只是pic 接去transceiver card 而已
没有用那个什么picdemz 的wo ..
我blur blur 了

config bit 我已经弄好了
之前你有跟我讲过了

#elif defined(18F25K20)
#pragma config FOSC = INTIO67 // Internal oscillator block, port function on RA6 and RA7  
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor disabled
#pragma config IESO = OFF // Oscillator Switchover mode disabled
#pragma config BOREN = ON // Brown-out Reset enabled and controlled by software (SBOREN is enabled)
#pragma config BORV = 27 // VBOR set to 2.7 V nominal
#pragma config WDTEN = OFF // WDT is controlled by SWDTEN bit of the WDTCON register  
#pragma config MCLRE = OFF // RE3 input pin enabled; MCLR disabled  
#pragma config HFOFST = OFF // The system clock is held off until the HF-INTOSC is stable.  
#pragma config PBADEN = OFF // PORTB<4:0> pins are configured as digital I/O on Reset  
#pragma config CCP2MX = PORTBE // CCP2 input/output is multiplexed with RB3  
#pragma config LVP = OFF // Single-Supply ICSP disabled   
#pragma config DEBUG = ON // Background debugger enabled, RB6 and RB7 are dedicated to In-Circuit Debug   
回复

使用道具 举报

发表于 18-11-2009 06:48 PM | 显示全部楼层
原帖由 ^Hins86^ 于 17-11-2009 05:28 PM 发表


我不了解是要怎样加hardware profile..还有什么circuit board 的
我只是pic 接去transceiver card 而已
没有用那个什么picdemz 的wo ..
我blur blur 了

config bit 我已经弄好了
之前你有跟我讲过了

# ...


现在你 没用microchip的板。不过他的program只是写给他的 development board 而已 。
如今你自己设计,一定会有一些minor得不一样。比如说 led iopin 之类的。
miwi program里面define 了一些development board的东东。比如说 什么 mcu,iopin怎么接,crystal speed.
当然 肯定没有你的咯。。。。所以你自己要 define.

你怎样知道 要修改哪里呢?
当然是 search microchip define 他自己 developement board 的地方 。 然后 在附近加入你自己的code.
search picdemz是我要知道应该要修改哪里。和 picdemz没关系 , 只是利用它而已。

头脑有点乱 。哈 , 写东西有点上下不接,希望你看得懂。

接下来看
C:\Microchip Solutions\P2P\P2P Node 1\HardwareProfile.h:59:     //#define PICDEMZ
你在附近会卡看到一些其他的board.default是 #define EXPLORER18,没错的话。这行是给 compiler知道等下compile program的时候 ,要compile什么。 给 picdemz, explorer 18, explorer 16还是其他的 。这里你得define自己的 board.可以是 WO_DE_BOARD,看你喜欢。然后其他的 comment.default也 comment起来 。当然你只能选一个。一个 program怎么可以给 两个 board用呢。
回复

使用道具 举报

 楼主| 发表于 18-11-2009 08:23 PM | 显示全部楼层
原帖由 fritlizt 于 18-11-2009 06:48 PM 发表


现在你 没用microchip的板。不过他的program只是写给他的 development board 而已 。
如今你自己设计,一定会有一些minor得不一样。比如说 led iopin 之类的。
miwi program里面define 了一些development boar ...


那我之后要弄这个board 出来的吗?
还是我只是根据它(microchip development board) 里有的东西(i/on pin等等)
一模一样的define 另一个名出来而已,而其实我的tranceiver card 就只是接去pic18f25k20 而已?
而那些 i/o pin 还有其他东西就是define 给pic18f25k20 的pin 来得?
这就是我so far 不了解要怎样开始弄的原因

另外,我想请问下visual basic 用serial port send data 的default是什么format(binary.hex,ascii) 呢?

不好意思har...我好像一面用很多东西不明白
一面麻烦你

[ 本帖最后由 ^Hins86^ 于 19-11-2009 06:39 PM 编辑 ]
回复

使用道具 举报

 楼主| 发表于 21-11-2009 10:22 PM | 显示全部楼层
我已经edit 了
不知道对不对
请帮忙过目以下。。很赶很赶。。时间剩下不多了


回复

使用道具 举报

发表于 22-11-2009 04:18 PM | 显示全部楼层


先讲这个, 差不多了。
#define SPI_SDI     PORTCbits.RC4               
#define SDI_TRIS    TRISCbits.TRISC4
#define SPI_SDO     LATCbits.LATC5               
#define SDO_TRIS    TRISCbits.TRISC5
#define SPI_SCK     LATCbits.LATC3               
#define SCK_TRIS    TRISCbits.TRISC3

这几个其实你不需要。 因为用hardware spi,这个是software spi pin assignment.
接下来是你的push button, led.你schematics 里面,你的push button和led接在哪里?
有schematics 吗?
回复

使用道具 举报

发表于 22-11-2009 04:27 PM | 显示全部楼层


这个有点问题 。
上面那个#elif define (NICKY), 就没有了?
其实这里的define最主要是关于
INTCONbits.GIEH = 1; 这个bit 的define.
18f25k20也是这个没变。
explorer16由于某些原因, 这里不需要define 这个bit 的initial state.
所以应该是

  1.    #if defined(PICDEMZ) || defined(PIC18_EXPLORER)
  2.         INTCONbits.GIEH = 1;
  3.         #elif defined(MY_BOARD)
  4.         INTCONbits.GIEH = 1;
  5.     #elif defined(EXPLORER16)
  6.     #else
  7.         #error "Unknown board.  Please initialize board as required."
  8.     #endif
复制代码


接下来, 更不明白了。printf那里rb1 on nicky, rb2 on nicky, d1 on nickt, d2 on nicky.这些你怎么得来的?
怎么和你的
        #define PUSH_BUTTON_1 PORTBbits.RB5
        #define PUSH_BUTTON_2 PORTBbits.RB4
        #define LED_1 LATAbits.LATA0
        #define LED_2 LATAbits.LATA1
这里不一样啊???

printf只是把info 通过uart print 出去。 通过max3232你可以在hyper terminal看到这些info.其实不是很重要。他的作用就只是"for ur information"
回复

使用道具 举报


ADVERTISEMENT

发表于 22-11-2009 04:42 PM | 显示全部楼层


这个没有看到complete 的code.很难给comment.不过我相信你miss了一点东西。
internal osc selection.
看你的clock_freq是16mhz,所以你应该要把clock switch 去16mhz. internal clock.
看datasheet有讲到
The System Clock Select bits, SCS<1:0>, select the
main clock source. The available clock sources are
&#8226; Primary clock defined by the FOSC<3:0> bits of
CONFIG1H. The primary clock can be the primary
oscillator, an external clock, or the internal oscillator
block.
&#8226; Secondary clock (Timer1 oscillator)
&#8226; Internal oscillator block (HFINTOSC and
LFINTOSC).
你需要在board init加入这个
  1. OSCCON = 0x72;                                   //16mhz internal clock
  2.                 while (!(OSCCON & 0x40));        //wait till clock stable
复制代码


如果可以,回复code的时候用<插入代码>来回复。print screen的话, 我要copy很辛苦。
回复

使用道具 举报

 楼主| 发表于 22-11-2009 04:58 PM | 显示全部楼层
原帖由 fritlizt 于 22-11-2009 04:18 PM 发表


先讲这个, 差不多了。
#define SPI_SDI     PORTCbits.RC4               
#define SDI_TRIS    TRISCbits.TRISC4
#define SPI_SD ...


har... 我没有你讲的schematic wor
怎样好。。。...
回复

使用道具 举报

 楼主| 发表于 22-11-2009 05:02 PM | 显示全部楼层
原帖由 fritlizt 于 22-11-2009 04:27 PM 发表


这个有点问题 。
上面那个#elif define (NICKY), 就没有了?
其实这里的define最主要是关于
INTCONbits.GIEH = 1; 这个bit 的def ...

这个等我edit 了再post 上来har...
rb1 on nicky, rb2 on nicky, d1 on nickt, d2 on nicky 我以为只是要自己define port 的名
哈哈。。我搞乱了
回复

使用道具 举报

发表于 22-11-2009 05:02 PM | 显示全部楼层
给你我的example.
修改program support 25k20的。
过了这关,可以compile, load进去25k20就很靠近了。。。。
不多东西改,你需要的是明白。

*如果不明白#define是什么, 可以去google看看。 属于基本的c programming preprocessor。这个很重要。

第一:这里我插入了我自己的definition.我跟compiler说,我要用my_board,你compile的时候,只需要compile my board 的code给我就行了。 其他的可以ignore.
  1.         #define MY_BOARD
  2.     //#define PICDEMZ
  3.     //#define PIC18_EXPLORER
  4.     //#define EXPLORER16
复制代码


第二:我现在有myboard了。 program里面有一些需要用到的constant我必须define.
没有define这些, compiler 不懂我的clock frequency是多少。
不懂我的spi在什么 pin.
我的button/ led在什么pin compiler也不懂。
所以这里主要是define我的hardware 特征。

  1. #if defined(MY_BOARD)
  2.             #define CLOCK_FREQ 16000000
  3.             // Transceiver Configuration
  4.             #define RFIF INTCONbits.INT0IF
  5.             #define RFIE INTCONbits.INT0IE
  6.             #define PHY_CS LATCbits.LATC0
  7.             #define PHY_CS_TRIS TRISCbits.TRISC0
  8.             #define PHY_RESETn LATCbits.LATC2
  9.             #define PHY_RESETn_TRIS TRISCbits.TRISC2
  10.             #define PHY_WAKE LATCbits.LATC1
  11.             #define PHY_WAKE_TRIS TRISCbits.TRISC1
  12.             
  13.             #define PUSH_BUTTON_1 PORTBbits.RB5
  14.             #define PUSH_BUTTON_2 PORTBbits.RB4
  15.             #define LED_1 LATAbits.LATA0
  16.             #define LED_2 LATAbits.LATA1
  17.             
  18.             #define PUSH_BUTTON_1_TRIS TRISB5
  19.             #define PUSH_BUTTON_2_TRIS TRISB4
  20.             #define LED_1_TRIS TRISA0
  21.             #define LED_2_TRIS TRISA1
  22.             
  23.             #define RF_INT_PIN PORTBbits.RB0
  24.                 #define RF_INT_TRIS TRISBbits.TRISB0
  25.             #define TMRL TMR0L
  26.         #endif
复制代码


第三:当然board initialization不可能每个board都一样。 你也要有自己的board initialization.
这个需要根据需求和你的电路来做。 我的是这样。 io呢, 和picdemz都很相近。基本上可以直接抄。
我设计电路的时候为了避免太多的不一样, io, button都和picdemz的一样。
hardware spi这样巧也在同样的pin.
当然mcu 上的不同, 我加入了一点代码在clock osc那里, 也就是
  1. OSCCON = 0x72;                   //16mhz internal clock
  2. while (!(OSCCON & 0x40));    //wait till clock stable
复制代码
  1. #elif defined(MY_BOARD)
  2.         WDTCONbits.SWDTEN = 0;                 //disable WDT
  3.                 OSCCON = 0x72;                                   //16mhz internal clock
  4.                 while (!(OSCCON & 0x40));        //wait till clock stable
  5.         
  6.         // Switches S2 and S3 are on RB5 and RB4 respectively. We want interrupt-on-change
  7.         INTCON = 0x00;
  8.         
  9.         // There is no external pull-up resistors on S2 and S3. We will use internal pull-ups.
  10.         // The MRF24J40 is using INT0 for interrupts
  11.         // Enable PORTB internal pullups
  12.         INTCON2 = 0x00;
  13.         INTCON3 = 0x00;
  14.    
  15.         // Make PORTB as input - this is the RESET default
  16.         TRISB = 0xff;
  17.    
  18.         // Set PORTC control signal direction and initial states
  19.         // disable chip select
  20.         LATC = 0xfd;
  21.    
  22.         // Set the SPI module for use by Stack
  23.         TRISC = 0xD0;
  24.    
  25.         // Set the SPI module
  26.         SSPSTAT = 0xC0;
  27.         SSPCON1 = 0x20;
  28.    
  29.         // D1 and D2 are on RA0 and RA1 respectively, and CS of TC77 is on RA2.
  30.         // Make PORTA as digital I/O.
  31.         // The TC77 temp sensor CS is on RA2.
  32.         ADCON1 = 0x0F;
  33.    
  34.         // Deselect TC77 (RA2)
  35.         LATA = 0x04;
  36.    
  37.         // Make RA0, RA1, RA2 and RA4 as outputs.
  38.         TRISA = 0xF8;
  39.         
  40.         PHY_CS = 1;             //deselect the MRF24J40
  41.         PHY_CS_TRIS = 0;        //make chip select an output   
  42.         
  43.         RFIF = 0;               //clear the interrupt flag
  44.    
  45.         RCONbits.IPEN = 1;
  46.         
  47.         INTCON2bits.INTEDG0 = 0;
复制代码


第四:也就是这里。原因楼上有,不多说。
你可以用
  1. #if defined(PICDEMZ) || defined(PIC18_EXPLORER)
  2.         INTCONbits.GIEH = 1;
  3.         #elif defined(MY_BOARD)
  4.         INTCONbits.GIEH = 1;
  5.     #elif defined(EXPLORER16)
  6.     #else
  7.         #error "Unknown board.  Please initialize board as required."
  8.     #endif
复制代码

或者这个,都一样的, 给个机会你想想看。
  1. #if defined(PICDEMZ) || defined(PIC18_EXPLORER) || defined(MY_BOARD)
  2.         INTCONbits.GIEH = 1;
  3.     #elif defined(EXPLORER16)
  4.     #else
  5.         #error "Unknown board.  Please initialize board as required."
  6.     #endif
复制代码


第五:
万事俱备, 只欠东风。。。。
就差config bit 而已。
这个已经讲过了, 不在多讲。 我的config bit setting是
  1. #elif defined(__18F25K20)
  2.         #pragma config FOSC = INTIO67                //internal oscillator. ra6,7 as i/o
  3.         #pragma config FCMEN = OFF                        //fail safe clock disable
  4.         #pragma config IESO = OFF                        //Oscillator Switchover mode disabled
  5.         #pragma config BOREN = ON                        //Brown-out Reset enabled and controlled by software (SBOREN is enabled)
  6.         #pragma config BORV = 27                        //VBOR set to 2.7 V nominal
  7.         #pragma config WDTEN = OFF                        //WDT is controlled by SWDTEN bit of the WDTCON register
  8.         #pragma config MCLRE = OFF                        //RE3 input pin enabled; MCLR disabled
  9.         #pragma config HFOFST = OFF                        //The system clock is held off until the HF-INTOSC is stable
  10.         #pragma config PBADEN = OFF                        //PORTB<4:0> pins are configured as digital I/O on Reset
  11.         #pragma config CCP2MX = PORTBE                //CCP2 input/output is multiplexed with RB3
  12.         #pragma config LVP = OFF                        //Single-Supply ICSP disabled
  13.         #pragma config DEBUG = ON                        //Background debugger enabled, RB6 and RB7 are dedicated to In-Circuit Debug
复制代码


就只是这样。 楼主, 在你拥有的时间,要明白我讲的东西, 其实绰绰有余。。。。不要担心。
不过看起来一些基本的东西, 你还不是掌握得很好。需要努力。 我不可能在这个贴连pic + c programming都讲得一清二楚, 你要明白,一些东西, 你要自修。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 22-5-2024 01:09 PM , Processed in 0.067370 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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