• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::

論壇索引


Board index » All Posts (mechwu)




Re: 請問輸出腳的問題
#71
資深會員
資深會員


參照:

Ryang 寫道:
mechwu,

真有一把刷子,感謝您對CCS的問題解答。

ICD2要怎樣寄過去呢?


Ryang 大大:

可以換 PICDEM-Z 嗎?謝謝謝謝啦
加上我買的一套,就有四塊 ZigBee 板可以玩 mesh 啦
謝謝謝謝囉

發表於: 2005/3/9 17:37
頂部


Re: About A/D sample frequency and resolution
#72
資深會員
資深會員


參照:

fish512 寫道:
非常感谢大家的帮助,给了我很大的信心

冒昧的再提个问题:

模数转换器与数模转换器可不可以单独使用,即不与控制 器(单片机)相连,加晶振和电源, 也能实现改变采样频率和量化比特?
PIC单片机如何进行数字信号处理?
是否进行A/D D/A 转换前后必须得加模拟滤波器?参数如何设置?


1. 模数转换器若不與單片機連接,數字要傳去哪裡?数模转换器若不與單片機連接,數字要從哪裡來?沒意義喔

2. PIC单片机如何进行数字信号处理 ... 不就一堆算數運算嗎,寫在程式裡就好啦

3. 模拟滤波器 ... analog filter ... 看需求啦,不一定需要

先去買本書,買塊實驗版,買套編譯器,動手做,拿示波器觀察 ... 多言無益,學而不思則罔,思而不學則殆,多動手吧

發表於: 2005/3/9 10:27
頂部


Re: 請問輸出腳的問題
#73
資深會員
資深會員


參照:

mechwu 寫道:

用 input( PIN_B0) 即可讀取 PIN_B0的目前狀態



警告!小心副作用!

若使用 #use standard_io(B) ... 這是默認 default 設定

則 input( PIN_B0) 會先將 PIN_B0 改為輸入腳!

請仔細看看 LST 檔的組合語言

假設你要 B0 做輸出,又要讀回 B0 的狀態,則有三個方法
1. 請用 input_state( PIN_B0 ),不會改 TRIS,3.207 版以上才有這個指令
2. 用 #use fixed_io(B),自己設 TRIS,用 input 讀回
3. 用 bit_test() 指令
#byte PORTB=0x06 // PIC16
x = bit_test(PORTB, 0); // 讀回

#bit RB0 = 0x06.0
x = RB0; // 讀回

多看看 LST 檔編出的組合語言吧

又,output_high(PIN_B0) 對於 PIC16 是操作 PORTB,對於 PIC18 則操作 LATB,解決 RMW 問題。

發表於: 2005/3/9 9:49
頂部


Re: 請問輸出腳的問題
#74
資深會員
資深會員


參照:

Ryang 寫道:
不知道你是用那家的C, 要讓一隻腳變 Hi 或 Low 怎麼會那麼複雜。


這是 CCS 為了跨 PIC16, PIC18 移植性的考慮,以及自動設 TRIS,以及 RMW 考慮 ... 所以才會變成這樣的函數,呵呵,花了我不少時間才體會到他的苦心。

發表於: 2005/3/8 21:48
頂部


Re: 請問輸出腳的問題
#75
資深會員
資深會員


參照:

jjak 寫道:
在C的寫法下,我可以用output_low(PIN_B0)及output_high(PIN_B0)
讓輸出腳位PIN_B0動作
但我要怎麼知道PIN_B0的目前狀態呢? 是high還是low?


這是 CCS 的 C

用 input( PIN_B0) 即可讀取 PIN_B0的目前狀態

問這種問題之前,請先看看 線上說明 吧,Help -> index -> output_high -> 相關指令 See Also 就有列出一堆指令

Also See:
input(), output_low(), output_float(), output_high(), output_bit(), output_x(), #use xxxx_io




發表於: 2005/3/8 21:44
頂部


Re: About A/D sample frequency and resolution
#76
資深會員
資深會員


采样频率 不是 Tad,Tad 是轉換一個 bit 所需的時間,
采样频率 是每秒鐘採樣的次數。

以下是用 CCS 公司的 C-compiler 寫的範例

// AD_DA.c --------------------------------------------------------------------
//
// Function:
//
// 1. 10-bit ADC, Sampling Frequency:  20 Hz, take sample every 50 msec
//                convert 0 ~ 5 volt into 0 ~ 1023
//
// 2. PWM DA at PIN_C2 using 19.53 kHz PWM with R-C low-pass, 1 kohm - 10 uF
//                convert 0 ~ 1023 into 0 ~ 100% duty PWM signal
//
// 3. RS232 printout at 115200 baud rate
//
#include <16F877.h>
#device  ADC=10            // select 10 bit AD, or, ADC=8 for 8 bit AD

#fuses   HS, NOLVP, PUT, NOWDT

#use delay(clock=20000000) // 20 MHz X'tal
#use rs232(baud=115200,xmit=PIN_C6,rcv=PIN_C7)

void main()
{
   
int16 ad_data;
   
   
printf("rnn PIC16F877 ADC and PWM_DAC test ... rn ");
   
   
setup_adc_portsAN0 );          // set PIN_RA0/AN0 as analog input
   
setup_adcADC_CLOCK_DIV_32 );   // Tad= 32*T_osc= 1.6 usec/bit at 20 MHz
                                    // Tconv= (10 bit + 2)* 1.6 = 19.2 usec

   
setup_ccp1CCP_PWM );           // configure CCP1 (RC2) as PWM1
   
setup_timer_2(T2_DIV_BY_1,255,1);// 19.53 kHz PWM with 20 MHz X'tal

   
while(1)
   {
      
set_adc_channel);   // select channel, S/H Cap. start charging
      
delay_us 60 );        // wait for S/H Cap. reach 1/2 LSB accuracy
      
ad_data read_adc();   // open S/H, start ADC, T_conversion ~ 20 us,

      
set_pwm1_duty(ad_data); // send AD data to PWM output at PIN_C2
                              // set_pwm1_duty(1023) will generate 100% duty
                              
      
printf("%lu ",ad_data); // print out data to TTL-RS232 at PIN_C6

      
delay_ms50 );         // delay loop, set sampling freq ~ 20 Hz
   
}
}

發表於: 2005/3/7 11:20
頂部


Re: About A/D sample frequency and resolution
#77
資深會員
資深會員


1. resolution: you got only two choice with hardware, 8 or 10 bits. you can chop it down to 4 bit at your wish.

2. sampling freq.: you can use either timer interrupt or simply delay loop.

3. D/A: you can use either external DA or built-in PWM with simple external R-C low-pass.

Please specify what kind of program you want, C code or Assembly ?

發表於: 2005/3/5 10:06
頂部


Re: AD 問題
#78
資深會員
資深會員


參照:
所以每次Channel切換時就需先延遲20uS後再轉換。


上述方案的前提是,信號源的 輸出阻抗 要小於 10 kohm

若信號源的輸出阻抗大於 10 kohm,我用的延遲時間是

(R_source / 10 kohm) * 10 us + 10 us

比技術手冊上的公式稍微簡單一點,也比較好記

發表於: 2005/3/4 10:14
頂部


Re: 可喜可賀!Microchip Taiwan網站登錄會員突破1000人!有沒有人建議辦個什麼慶祝活動啊?
#79
資深會員
資深會員


華特?我有灌那麼多水嗎? 呼呼

這 ... 真是太令人感動了,嗚嗚嗚

但是,人家小弟我用 bootloader,一個team裡面十幾個人也只需要一顆 ICD2 ... 這這這 ...

人家想要玩 PICDEM-Z,要玩 ZigBee 啦,可是,可是,
人家昨天已經上那個 buy.microchip.com 把卡都刷了,嗚嗚
還要等到四月才拿得到,嗚嗚嗚嗚

Ryang 大大:

我這 ... ICD2 就捐出來啦,請您發落囉
或是遞補,或是抽獎,或是換咖啡餅乾花生辦個版聚,呵呵,大家高興就好啦

謝謝囉

mechwu

多喝多灌,有益健康,醫生說我感冒要多喝水,大家多保重

ps. 這篇對岸的帖子不錯看喔
http://www.goldenchip.com.cn/gdbbs/di ... melimit=&operator=&page=1

發表於: 2005/3/3 21:17
頂部


Re: 可喜可賀!Microchip Taiwan網站登錄會員突破1000人!有沒有人建議辦個什麼慶祝活動啊?
#80
資深會員
資深會員



辦個抽獎咩 ... 送老鼠送ICD2 ... 呵呵

這樣才更會人氣旺旺喔

發表於: 2005/3/1 17:45
頂部



« 1 ... 5 6 7 (8) 9 10 11 ... 16 »



:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------