Skocz do zawartości

zuba1

Users
  • Zawartość

    241
  • Rejestracja

  • Ostatnio

  • Wygrane dni

    4

zuba1 zajął 1. miejsce w rankingu.
Data osiągnięcia: 13 maja 2013.

Treści użytkownika zuba1 zdobyły tego dnia najwięcej polubień!

O zuba1

  • Urodziny 20.08.1997

Informacje

Ostatnio na profilu byli

1 391 wyświetleń profilu

Osiągnięcia użytkownika zuba1

Stały bywalec

Stały bywalec (9/19)

  • Za 25 postów
  • Za 5 postów
  • Za 100 postów
  • Juror
  • Młodszy Juror

Odznaki

35

Reputacja

  1. Koszty wydruku i bardziej ogarniętych czujników TOF a nawet lidaru 360 + dobry komputer pokładowy, stacja dokująca nie wspominając o oprogramowaniu, aplikacji mobilnej i pewnie wielu innych rzeczach znacząco przerosną koszty robota sprzątającego z rynku. Przykładowo taki Xiaomi MOP PRO kosztuje jakieś 1,2k a można go sobie poprzez API zintegrować z jakimś własnym smarthome.
  2. Jest to kość pochodząca z płytki esp8266. Na analizatorze po wywołaniu komendy zapisu wartości np. 0x33 po wysłaniu komendy odczytu, z przebiegów wynika że układ odpowiada wartością 0x33 więc układ jest inicjalizowany i odpowiada prawidłowo. Tylko nie wiem dlaczego to co było na kablu, nie trafia do bufforu.
  3. Cześć. Borykam się z SPI w układzie stm32f051. Komunikuję się z układem zewnętrznej pamięci flash w celu zapisu rekordów pomiaru dalmierza. Natrafiłem na dziwną przypadłość. Układ startuje i wysyła dane do układu prawidłowo (sprawdzone analizatorem). Układ też chętnie odpowiada zgodnie z oczekiwaniami. Ale gdy chcę sprawdzić co odebrał, w debuggerze wyświetla mi się 0x00 lub 0xFF tak jak by noga była zwarta do masy lub do plusa (połączenie pewne, pomiar analizatora dokonany niedaleko wyprowadzenia). Oczywiście dzieje się tak tylko w momencie gdy zakomentuję while-a czekającego na reset flagi odebrania danych. W innym wypadku program zawiesi się na tym etapie. Dodaję kod: /** ****************************************************************************** * @file main.c * @author Ac6 * @version V1.0 * @date 01-December-2013 * @brief Default main function. ****************************************************************************** */ #include "stm32f0xx.h" #include "stm32f0_discovery.h" volatile uint32_t timer_ms = 0; #define PCS 1 #define NCS 0 void SysTick_Handler() //handler przerwania { if (timer_ms) { timer_ms--; } } void delay_ms(int time) { timer_ms = time; while (timer_ms) {}; } uint8_t spi(uint8_t byte,uint8_t mode){ uint8_t data_rev; GPIO_ResetBits(GPIOA, GPIO_Pin_4); //cs to low while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET); SPI_SendData8(SPI1, byte); while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET); data_rev=SPI_ReceiveData8(SPI1); if(mode==PCS) GPIO_SetBits(GPIOA, GPIO_Pin_4); //cs to high return data_rev; } void flash_init(){ spi(0x06,PCS); delay_ms(50); //small delay spi(0x66,PCS); delay_ms(50); spi(0x99,PCS); delay_ms(50); } uint8_t flash_read(uint8_t addr){ uint8_t data; spi(0x03,NCS); spi(0x00,NCS); spi(0x00,NCS); spi(addr,NCS); data = spi(0xFF,PCS); return data; } void flash_write(uint8_t addr, uint8_t data){ spi(0x02,NCS); spi(0x00,NCS); spi(0x00,NCS); spi(addr,NCS); spi(data,PCS); } int main(void) { //sys clock config SysTick_Config(SystemCoreClock / 1000); //przerwanie co 1ms //spi config RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); SPI_InitTypeDef SPI_InitTypeDefStruct; SPI_InitTypeDefStruct.SPI_Direction = SPI_Direction_2Lines_FullDuplex; SPI_InitTypeDefStruct.SPI_Mode = SPI_Mode_Master; SPI_InitTypeDefStruct.SPI_DataSize = SPI_DataSize_8b; SPI_InitTypeDefStruct.SPI_CPOL = SPI_CPOL_High; SPI_InitTypeDefStruct.SPI_CPHA = SPI_CPHA_2Edge; SPI_InitTypeDefStruct.SPI_NSS = SPI_NSS_Soft; SPI_InitTypeDefStruct.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8 ; SPI_InitTypeDefStruct.SPI_FirstBit = SPI_FirstBit_MSB; SPI_Init(SPI1, &SPI_InitTypeDefStruct); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); GPIO_InitTypeDef GPIO_InitTypeDefStruct; GPIO_InitTypeDefStruct.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; GPIO_InitTypeDefStruct.GPIO_Mode = GPIO_Mode_AF; GPIO_InitTypeDefStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitTypeDefStruct.GPIO_OType = GPIO_OType_PP; GPIO_InitTypeDefStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &GPIO_InitTypeDefStruct); GPIO_InitTypeDefStruct.GPIO_Pin = GPIO_Pin_4; GPIO_InitTypeDefStruct.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitTypeDefStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitTypeDefStruct.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitTypeDefStruct.GPIO_OType = GPIO_OType_PP; GPIO_Init(GPIOA, &GPIO_InitTypeDefStruct); GPIO_SetBits(GPIOA, GPIO_Pin_4); //cs to high SPI_Cmd(SPI1, ENABLE); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE); GPIO_InitTypeDefStruct.GPIO_Pin = GPIO_Pin_9; GPIO_InitTypeDefStruct.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitTypeDefStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitTypeDefStruct.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitTypeDefStruct.GPIO_OType = GPIO_OType_PP; GPIO_Init(GPIOC, &GPIO_InitTypeDefStruct); GPIO_ResetBits(GPIOC, GPIO_Pin_4); //flash init delay_ms(2000); flash_init(); uint8_t data=0; while (1) { flash_write(0x01,0x33); delay_ms(100); data=flash_read(0x01); if (data==0x33) { GPIO_SetBits(GPIOC, GPIO_Pin_9); }else{ GPIO_ResetBits(GPIOC, GPIO_Pin_9); } delay_ms(1000); } }
  4. Mam pomysł. Może podłączę go do arduino, wgram originalny program i podepnę pod to drugą atmegę. Następnie będę sprawdzał zbocze clk i w danym zboczu będę zczytywał wartość binarną. Finalnie wyślę je na wyświetlacz LCD. Co myślicie? Czy metoda podsłuchania okaże się skuteczna?
  5. Witam. Na wstępnie klasyk do Pana moderatora-jak złe miejsce to proszę przenieś. Mam niecodzienny problem. Ostatnio wraz z zabawą w arduino nabyłem czujnik gestów APDS9960 na płytce spartak funa. Z racji że wiele moich projektów opiera się o język Bascom. Aplikacja mojego czujnika wymusza na mnie zastosowanie bascoma a instalowanie procesora mostka między czujnikiem a główna aplikacją odpada. Jako że w arduino jestem że tak powiem zielony postanowiłem przepisać wszystko na bascoma. Ambitnie pochwyciłem biblioteki i przepisałem całą instrukcję init-Najpewniej błędnie. Z datasheta wiem co nieco lecz na jego podstawie nie potrafię sklepać niczego pewnego. Po prostu mam mętlik z tymi rejestrami.Nie wiem co mam czytać. Żeby nie było dodaję wszelkie materiały które udało mi się zgromadzić. Na początek co chcę osiągnąć: -chcę rozpoznawać podstawowe gesty -sprawdzać obecną gamę barw RGB -sprawdzać jasność choć to można osiągnąć na dwa sposoby czyli albo przez RGB lub skorzystać z czwartego sensora w układzie czyli W- rozpoznający całą składnię barwy białej Obecne materiały: Dysponuję Kodem z arduino: +/** + * @file SparkFun_APDS-9960.h + * @brief Library for the SparkFun APDS-9960 breakout board + * @author Shawn Hymel (SparkFun Electronics) + * + * @copyright This code is public domain but you buy me a beer if you use + * this and we meet someday (Beerware license). + * + * This library interfaces the Avago APDS-9960 to Arduino over I2C. The library + * relies on the Arduino Wire (I2C) library. to use the library, instantiate an + * APDS9960 object, call init(), and call the appropriate functions. + */ + +#ifndef SparkFun_APDS9960_H +#define SparkFun_APDS9960_H + +#include <Arduino.h> + +/* Debug */ +#define DEBUG 0 + +/* APDS-9960 I2C address */ +#define APDS9960_I2C_ADDR 0x39 + +/* Gesture parameters */ +#define GESTURE_THRESHOLD_OUT 10 +#define GESTURE_SENSITIVITY_1 50 +#define GESTURE_SENSITIVITY_2 20 + +/* Error code for returned values */ +#define ERROR 0xFF + +/* Acceptable device IDs */ +#define APDS9960_ID_1 0xAB +#define APDS9960_ID_2 0x9C + +/* Misc parameters */ +#define FIFO_PAUSE_TIME 30 // Wait period (ms) between FIFO reads + +/* APDS-9960 register addresses */ +#define APDS9960_ENABLE 0x80 +#define APDS9960_ATIME 0x81 +#define APDS9960_WTIME 0x83 +#define APDS9960_AILTL 0x84 +#define APDS9960_AILTH 0x85 +#define APDS9960_AIHTL 0x86 +#define APDS9960_AIHTH 0x87 +#define APDS9960_PILT 0x89 +#define APDS9960_PIHT 0x8B +#define APDS9960_PERS 0x8C +#define APDS9960_CONFIG1 0x8D +#define APDS9960_PPULSE 0x8E +#define APDS9960_CONTROL 0x8F +#define APDS9960_CONFIG2 0x90 +#define APDS9960_ID 0x92 +#define APDS9960_STATUS 0x93 +#define APDS9960_CDATAL 0x94 +#define APDS9960_CDATAH 0x95 +#define APDS9960_RDATAL 0x96 +#define APDS9960_RDATAH 0x97 +#define APDS9960_GDATAL 0x98 +#define APDS9960_GDATAH 0x99 +#define APDS9960_BDATAL 0x9A +#define APDS9960_BDATAH 0x9B +#define APDS9960_PDATA 0x9C +#define APDS9960_POFFSET_UR 0x9D +#define APDS9960_POFFSET_DL 0x9E +#define APDS9960_CONFIG3 0x9F +#define APDS9960_GPENTH 0xA0 +#define APDS9960_GEXTH 0xA1 +#define APDS9960_GCONF1 0xA2 +#define APDS9960_GCONF2 0xA3 +#define APDS9960_GOFFSET_U 0xA4 +#define APDS9960_GOFFSET_D 0xA5 +#define APDS9960_GOFFSET_L 0xA7 +#define APDS9960_GOFFSET_R 0xA9 +#define APDS9960_GPULSE 0xA6 +#define APDS9960_GCONF3 0xAA +#define APDS9960_GCONF4 0xAB +#define APDS9960_GFLVL 0xAE +#define APDS9960_GSTATUS 0xAF +#define APDS9960_IFORCE 0xE4 +#define APDS9960_PICLEAR 0xE5 +#define APDS9960_CICLEAR 0xE6 +#define APDS9960_AICLEAR 0xE7 +#define APDS9960_GFIFO_U 0xFC +#define APDS9960_GFIFO_D 0xFD +#define APDS9960_GFIFO_L 0xFE +#define APDS9960_GFIFO_R 0xFF + +/* Bit fields */ +#define APDS9960_PON 0b00000001 +#define APDS9960_AEN 0b00000010 +#define APDS9960_PEN 0b00000100 +#define APDS9960_WEN 0b00001000 +#define APSD9960_AIEN 0b00010000 +#define APDS9960_PIEN 0b00100000 +#define APDS9960_GEN 0b01000000 +#define APDS9960_GVALID 0b00000001 + +/* On/Off definitions */ +#define OFF 0 +#define ON 1 + +/* Acceptable parameters for setMode */ +#define POWER 0 +#define AMBIENT_LIGHT 1 +#define PROXIMITY 2 +#define WAIT 3 +#define AMBIENT_LIGHT_INT 4 +#define PROXIMITY_INT 5 +#define GESTURE 6 +#define ALL 7 + +/* LED Drive values */ +#define LED_DRIVE_100MA 0 +#define LED_DRIVE_50MA 1 +#define LED_DRIVE_25MA 2 +#define LED_DRIVE_12_5MA 3 + +/* Proximity Gain (PGAIN) values */ +#define PGAIN_1X 0 +#define PGAIN_2X 1 +#define PGAIN_4X 2 +#define PGAIN_8X 3 + +/* ALS Gain (AGAIN) values */ +#define AGAIN_1X 0 +#define AGAIN_4X 1 +#define AGAIN_16X 2 +#define AGAIN_64X 3 + +/* Gesture Gain (GGAIN) values */ +#define GGAIN_1X 0 +#define GGAIN_2X 1 +#define GGAIN_4X 2 +#define GGAIN_8X 3 + +/* LED Boost values */ +#define LED_BOOST_100 0 +#define LED_BOOST_150 1 +#define LED_BOOST_200 2 +#define LED_BOOST_300 3 + +/* Gesture wait time values */ +#define GWTIME_0MS 0 +#define GWTIME_2_8MS 1 +#define GWTIME_5_6MS 2 +#define GWTIME_8_4MS 3 +#define GWTIME_14_0MS 4 +#define GWTIME_22_4MS 5 +#define GWTIME_30_8MS 6 +#define GWTIME_39_2MS 7 + +/* Default values */ +#define DEFAULT_ATIME 219 // 103ms +#define DEFAULT_WTIME 246 // 27ms +#define DEFAULT_PROX_PPULSE 0x87 // 16us, 8 pulses +#define DEFAULT_GESTURE_PPULSE 0x89 // 16us, 10 pulses +#define DEFAULT_POFFSET_UR 0 // 0 offset +#define DEFAULT_POFFSET_DL 0 // 0 offset +#define DEFAULT_CONFIG1 0x60 // No 12x wait (WTIME) factor +#define DEFAULT_LDRIVE LED_DRIVE_100MA +#define DEFAULT_PGAIN PGAIN_4X +#define DEFAULT_AGAIN AGAIN_4X +#define DEFAULT_PILT 0 // Low proximity threshold +#define DEFAULT_PIHT 50 // High proximity threshold +#define DEFAULT_AILT 0xFFFF // Force interrupt for calibration +#define DEFAULT_AIHT 0 +#define DEFAULT_PERS 0x11 // 2 consecutive prox or ALS for int. +#define DEFAULT_CONFIG2 0x01 // No saturation interrupts or LED boost +#define DEFAULT_CONFIG3 0 // Enable all photodiodes, no SAI +#define DEFAULT_GPENTH 40 // Threshold for entering gesture mode +#define DEFAULT_GEXTH 30 // Threshold for exiting gesture mode +#define DEFAULT_GCONF1 0x40 // 4 gesture events for int., 1 for exit +#define DEFAULT_GGAIN GGAIN_4X +#define DEFAULT_GLDRIVE LED_DRIVE_100MA +#define DEFAULT_GWTIME GWTIME_2_8MS +#define DEFAULT_GOFFSET 0 // No offset scaling for gesture mode +#define DEFAULT_GPULSE 0xC9 // 32us, 10 pulses +#define DEFAULT_GCONF3 0 // All photodiodes active during gesture +#define DEFAULT_GIEN 0 // Disable gesture interrupts + +/* Direction definitions */ +enum { + DIR_NONE, + DIR_LEFT, + DIR_RIGHT, + DIR_UP, + DIR_DOWN, + DIR_NEAR, + DIR_FAR, + DIR_ALL +}; + +/* State definitions */ +enum { + NA_STATE, + NEAR_STATE, + FAR_STATE, + ALL_STATE +}; + +/* Container for gesture data */ +typedef struct gesture_data_type { + uint8_t u_data[32]; + uint8_t d_data[32]; + uint8_t l_data[32]; + uint8_t r_data[32]; + uint8_t index; + uint8_t total_gestures; + uint8_t in_threshold; + uint8_t out_threshold; +} gesture_data_type; + +/* APDS9960 Class */ +class SparkFun_APDS9960 { +public: + + /* Initialization methods */ + SparkFun_APDS9960(); + ~SparkFun_APDS9960(); + bool init(); + uint8_t getMode(); + bool setMode(uint8_t mode, uint8_t enable); + + /* Turn the APDS-9960 on and off */ + bool enablePower(); + bool disablePower(); + + /* Enable or disable specific sensors */ + bool enableLightSensor(bool interrupts = false); + bool disableLightSensor(); + bool enableProximitySensor(bool interrupts = false); + bool disableProximitySensor(); + bool enableGestureSensor(bool interrupts = true); + bool disableGestureSensor(); + + /* LED drive strength control */ + uint8_t getLEDDrive(); + bool setLEDDrive(uint8_t drive); + uint8_t getGestureLEDDrive(); + bool setGestureLEDDrive(uint8_t drive); + + /* Gain control */ + uint8_t getAmbientLightGain(); + bool setAmbientLightGain(uint8_t gain); + uint8_t getProximityGain(); + bool setProximityGain(uint8_t gain); + uint8_t getGestureGain(); + bool setGestureGain(uint8_t gain); + + /* Get and set light interrupt thresholds */ + bool getLightIntLowThreshold(uint16_t &threshold); + bool setLightIntLowThreshold(uint16_t threshold); + bool getLightIntHighThreshold(uint16_t &threshold); + bool setLightIntHighThreshold(uint16_t threshold); + + /* Get and set proximity interrupt thresholds */ + bool getProximityIntLowThreshold(uint8_t &threshold); + bool setProximityIntLowThreshold(uint8_t threshold); + bool getProximityIntHighThreshold(uint8_t &threshold); + bool setProximityIntHighThreshold(uint8_t threshold); + + /* Get and set interrupt enables */ + uint8_t getAmbientLightIntEnable(); + bool setAmbientLightIntEnable(uint8_t enable); + uint8_t getProximityIntEnable(); + bool setProximityIntEnable(uint8_t enable); + uint8_t getGestureIntEnable(); + bool setGestureIntEnable(uint8_t enable); + + /* Clear interrupts */ + bool clearAmbientLightInt(); + bool clearProximityInt(); + + /* Ambient light methods */ + bool readAmbientLight(uint16_t &val); + bool readRedLight(uint16_t &val); + bool readGreenLight(uint16_t &val); + bool readBlueLight(uint16_t &val); + + /* Proximity methods */ + bool readProximity(uint8_t &val); + + /* Gesture methods */ + bool isGestureAvailable(); + int readGesture(); + +private: + + /* Gesture processing */ + void resetGestureParameters(); + bool processGestureData(); + bool decodeGesture(); + + /* Proximity Interrupt Threshold */ + uint8_t getProxIntLowThresh(); + bool setProxIntLowThresh(uint8_t threshold); + uint8_t getProxIntHighThresh(); + bool setProxIntHighThresh(uint8_t threshold); + + /* LED Boost Control */ + uint8_t getLEDBoost(); + bool setLEDBoost(uint8_t boost); + + /* Proximity photodiode select */ + uint8_t getProxGainCompEnable(); + bool setProxGainCompEnable(uint8_t enable); + uint8_t getProxPhotoMask(); + bool setProxPhotoMask(uint8_t mask); + + /* Gesture threshold control */ + uint8_t getGestureEnterThresh(); + bool setGestureEnterThresh(uint8_t threshold); + uint8_t getGestureExitThresh(); + bool setGestureExitThresh(uint8_t threshold); + + /* Gesture LED, gain, and time control */ + uint8_t getGestureWaitTime(); + bool setGestureWaitTime(uint8_t time); + + /* Gesture mode */ + uint8_t getGestureMode(); + bool setGestureMode(uint8_t mode); + + /* Raw I2C Commands */ + bool wireWriteByte(uint8_t val); + bool wireWriteDataByte(uint8_t reg, uint8_t val); + bool wireWriteDataBlock(uint8_t reg, uint8_t *val, unsigned int len); + bool wireReadDataByte(uint8_t reg, uint8_t &val); + int wireReadDataBlock(uint8_t reg, uint8_t *val, unsigned int len); + + /* Members */ + gesture_data_type gesture_data_; + int gesture_ud_delta_; + int gesture_lr_delta_; + int gesture_ud_count_; + int gesture_lr_count_; + int gesture_near_count_; + int gesture_far_count_; + int gesture_state_; + int gesture_motion_; +}; + + #endif A teraz moje skromne wypociny w bascomie: 'test board atmega8 $regfile = "m8def.dat" $crystal = 8000000 Config Pinb.0 = Input Sw Alias Pinb.0 Config Portb.1 = Output Led Alias Portb.1 Config Portd = Output Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2 Config Lcd = 16 * 2 Cursor Off 'Cursor Blink Enable Interrupts Cls 'Config Adc = Single , Prescaler = Auto , Reference = Avcc 'Start Adc 'Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up 'Pwm1a = 100 'Pwm1b = 39 'program '********************************************************************************************* ' + #define Debug 0 Const Apds9960_i2c_addr = &H39 'Gesture parameters Const Gesture_threshold_out = 10 Const Gesture_sensitivity_1 = 50 Const Gesture_sensitivity_2 = 20 ' Error code for returned values Const Error = &HFF 'Acceptable device IDs Const Apds9960_id_1 = &HAB Const Apds9960_id_2 = &H9C 'Misc parameters */ Const Fifo_pause_time = 30 'Wait Period(ms) Between Fifo Reads 'APDS-9960 register addresses Const Apds9960_enable = &H80 Const Apds9960_atime = &H81 Const Apds9960_wtime = &H83 Const Apds9960_ailtl = &H84 Const Apds9960_ailth = &H85 Const Apds9960_aihtl = &H86 Const Apds9960_aihth = &H87 Const Apds9960_pilt = &H89 Const Apds9960_piht = &H8B Const Apds9960_pers = &H8C Const Apds9960_config1 = &H8D Const Apds9960_ppulse = &H8E Const Apds9960_control = &H8F Const Apds9960_config2 = &H90 Const Apds9960_id = &H92 Const Apds9960_status = &H93 Const Apds9960_cdatal = &H94 Const Apds9960_cdatah = &H95 Const Apds9960_rdatal = &H96 Const Apds9960_rdatah = &H97 Const Apds9960_gdatal = &H98 Const Apds9960_gdatah = &H99 Const Apds9960_bdatal = &H9A Const Apds9960_bdatah = &H9B Const Apds9960_pdata = &H9C Const Apds9960_poffset_ur = &H9D Const Apds9960_poffset_dl = &H9E Const Apds9960_config3 = &H9F Const Apds9960_gpenth = &HA0 Const Apds9960_gexth = &HA1 Const Apds9960_gconf1 = &HA2 Const Apds9960_gconf2 = &HA3 Const Apds9960_goffset_u = &HA4 Const Apds9960_goffset_d = &HA5 Const Apds9960_goffset_l = &HA7 Const Apds9960_goffset_r = &HA9 Const Apds9960_gpulse = &HA6 Const Apds9960_gconf3 = &HAA Const Apds9960_gconf4 = &HAB Const Apds9960_gflvl = &HAE Const Apds9960_gstatus = &HAF Const Apds9960_iforce = &HE4 Const Apds9960_piclear = &HE5 Const Apds9960_ciclear = &HE6 Const Apds9960_aiclear = &HE7 Const Apds9960_gfifo_u = &HFC Const Apds9960_gfifo_d = &HFD Const Apds9960_gfifo_l = &HFE Const Apds9960_gfifo_r = &HFF 'Bit fields Const Apds9960_pon = &B00000001 Const Apds9960_aen = &B00000010 Const Apds9960_pen = &B00000100 Const Apds9960_wen = &B00001000 Const Apsd9960_aien = &B00010000 Const Apds9960_pien = &B00100000 Const Apds9960_gen = &B01000000 Const Apds9960_gvalid = &B00000001 'On/Off definitions */ Const Aoff = 0 Const Aon = 1 'Acceptable parameters for setMode Const Apower = 0 Const Ambient_light = 1 Const Proximity = 2 Const Await = 3 Const Ambient_light_int = 4 Const Proximity_int = 5 Const Gesture = 6 Const All = 7 'LED Drive values Const Led_drive_100ma = 0 Const Led_drive_50ma = 1 Const Led_drive_25ma = 2 Const Led_drive_12_5ma = 3 'Proximity Gain (PGAIN) values Const Pgain_1x = 0 Const Pgain_2x = 1 Const Pgain_4x = 2 Const Pgain_8x = 3 'ALS Gain (AGAIN) values Const Again_1x = 0 Const Again_4x = 1 Const Again_16x = 2 Const Again_64x = 3 'Gesture Gain (GGAIN) values Const Ggain_1x = 0 Const Ggain_2x = 1 Const Ggain_4x = 2 Const Ggain_8x = 3 'LED Boost values */ Const Led_boost_100 = 0 Const Led_boost_150 = 1 Const Led_boost_200 = 2 Const Led_boost_300 = 3 'Gesture wait time values Const Gwtime_0ms = 0 Const Gwtime_2_8ms = 1 Const Gwtime_5_6ms = 2 Const Gwtime_8_4ms = 3 Const Gwtime_14_0ms = 4 Const Gwtime_22_4ms = 5 Const Gwtime_30_8ms = 6 Const Gwtime_39_2ms = 7 'Default values Const Default_atime = 219 '103ms Const Default_wtime = 246 '27ms Const Default_prox_ppulse = &H87 '16us , 8 Pulses Const Default_gesture_ppulse = &H89 '16us , 10 Pulses Const Default_poffset_ur = 0 '0 Offset Const Default_poffset_dl = 0 '0 Offset Const Default_config1 = &H60 'No 12x Wait(wtime) Factor Const Default_ldrive = 0 Const Default_pgain = 2 Const Default_again = 1 Const Default_pilt = 0 'Low Proximity Threshold Const Default_piht = 50 'High Proximity Threshold Const Default_ailt = &HFFFF 'Force Interrupt For Calibration Const Default_aiht = 0 Const Default_pers = &H11 '2 Consecutive Prox Or Als For Int. Const Default_config2 = &H01 ' No Saturation Interrupts Or Led Boost Const Default_config3 = 0 'Enable All Photodiodes , No Sai Const Default_gpenth = 40 'Threshold For Entering Gesture Mode Const Default_gexth = 30 'Threshold For Exiting Gesture Mode Const Default_gconf1 = &H40 '4 Gesture Events For Int. , 1 For Exit Const Default_ggain = 2 Const Default_gldrive = 0 Const Default_gwtime = 1 Const Default_goffset = 0 'No Offset Scaling For Gesture Mode Const Default_gpulse = &HC9 '32us , 10 Pulses Const Default_gconf3 = 0 'All Photodiodes Active During Gesture Const Default_gien = 0 'Disable Gesture Interrupts $lib "i2c_twi.lbx" Config Sda = Portc.4 Config Scl = Portc.5 Config Twi = 400000 ' Init TWBR und TWSR Twcr = &B00000100 ' nur TWEN setzen 'const Dim I As Word Dim A As Word Dim B As Byte Dim Dane(10) As Byte Led = 1 Gosub Apds_init Do Gosub Apds_odczyt Cls Upperline Lcd Dane(1) ; " " ; Dane(2) Lowerline Lcd Dane(7) ; " " ; Dane(6) Waitms 500 Loop Apds_init: I2cstart I2cwbyte Apds9960_atime I2cwbyte Default_atime I2cstop Waitms 5 I2cstart I2cwbyte Apds9960_wtime I2cwbyte Default_wtime I2cstop Waitms 5 I2cstart I2cwbyte Apds9960_ppulse I2cwbyte Default_prox_ppulse I2cstop Waitms 5 I2cstart I2cwbyte Apds9960_poffset_ur I2cwbyte Default_poffset_ur I2cstop Waitms 5 I2cstart I2cwbyte Apds9960_poffset_dl I2cwbyte DEFAULT_POFFSET_DL I2cstop Waitms 5 I2cstart I2cwbyte APDS9960_CONFIG1 I2cwbyte DEFAULT_CONFIG1 I2cstop Waitms 5 I2cstart I2cwbyte APDS9960_PERS I2cwbyte Default_pers I2cstop Waitms 5 I2cstart I2cwbyte APDS9960_CONFIG2 I2cwbyte Default_config2 I2cstop Waitms 5 I2cstart I2cwbyte APDS9960_CONFIG3 I2cwbyte Default_config3 I2cstop Waitms 5 I2cstart I2cwbyte APDS9960_GCONF1 I2cwbyte Default_gconf1 I2cstop Waitms 5 I2cstart I2cwbyte APDS9960_GOFFSET_U I2cwbyte Default_goffset I2cstop Waitms 5 I2cstart I2cwbyte APDS9960_GOFFSET_D I2cwbyte Default_goffset I2cstop Waitms 5 I2cstart I2cwbyte APDS9960_GOFFSET_L I2cwbyte Default_goffset I2cstop Waitms 5 I2cstart I2cwbyte APDS9960_GOFFSET_R I2cwbyte Default_goffset I2cstop Waitms 5 I2cstart I2cwbyte APDS9960_GPULSE I2cwbyte Default_gpulse I2cstop Waitms 5 I2cstart I2cwbyte APDS9960_GCONF3 I2cwbyte Default_gconf3 I2cstop Waitms 5 Return Apds_odczyt: I2cstart I2cwbyte &H39 I2cwbyte &H89 I2crbyte Dane(1) , Ack I2crbyte Dane(2) , Ack I2crbyte Dane(3) , Ack I2crbyte Dane(4) , Ack I2crbyte Dane(5) , Ack I2crbyte Dane(6) , Nack I2cstop Return Datashet: https://cdn.sparkfun.com/assets/learn_tutorials/3/2/1/Avago-APDS-9960-datasheet.pdf Tak więc panowie widzimy jak to mniej więcej wygląda -a konkretnie nie wygląda. Prosze o wszeklą pomoc. Główne doświatczonych Arduoinowców aby spróbowali rozpisać tą transmisję. Jeśli będę znał rejestry niepowinienem mieć problemów z resztą. Pozdrawiam i z góry dziękuję.
  6. Dlaczego więc Atmel nie zastosuje szybszych bramek. Przecież znane są już rozwiązania wydajniejsze a podejrzewam że 328 z wbudowanym PLL 80MHz był by łakomym kąskiem. Czy ta architektura nie obsłuży innych bramek?
  7. Ciekawe czy ten model też da się tak podkręcić jak zwykłą atmega328. Być może zainstalowali jakieś ograniczenie zegara? 😉 Ciekawe jak zniesie 20MHz i czy wyżej nie zacznie się wieszać 😉 Jak myślicie?
  8. Zamiast switch jest case. Nie w tym problem. tu chodzi bardziej o sam pid i jego spięcie z programem tak aby dawał się stroić i pracował sprawnie. Dziękuję za te cenne uwagi postaram się to poprawić. Ale na razie skupmy się na samym pidzie bo to on jest tu głównym problemem.
  9. Witam. Od pewnego czasu mam problem z moim quadrocopterem. Problem jest prosty. Przygotowuję dane o kącie wychylenia z filtru Kalmana, potem łączę go z danymi o chcianym wychyleniu i dodaję wartość do obecnej mocy silników. Potem ta wartość trafia do PID. PID stara się osiągnąć samą moc silników. Ale ta koncepcja jest błędna. Więc wymyśliłem inne rozwiązanie. Na PID podaję samą wartość wychylenia. PID stara się osiągnąć 0. Potem ta wartość z PIDa dodawana jest z mocą silników. Może mię ktoś nakierować jak ten problem rozwiązać?? Pid w obydwu przypadkach stroiłem metodą zieglera-nicholsa. Niestety nieskutecznie. 😐 . Podaję fragmet kodu z pierwszej koncepcji wraz z całym blokiem sterowania i nadawania kierunku lotu. Wszelka pomoc jest mile widziana. Pozdrawiam. '1 2 3 ' '4 0 6 ' '7 8 9 'baza ruchów If Kierunek = 0 Then Xx = 0 Yy = 0 End If If Kierunek = 1 Then Xx = 4 Yy = 4 End If If Kierunek = 2 Then Xx = 5 Yy = 0 End If If Kierunek = 3 Then Xx = 4 Yy = -4 End If If Kierunek = 4 Then Xx = 0 Yy = 5 End If If Kierunek = 6 Then Xx = 0 Yy = -5 End If If Kierunek = 7 Then Xx = -4 Yy = 4 End If If Kierunek = 8 Then Xx = -5 Yy = 0 End If If Kierunek = 9 Then Xx = -4 Yy = -4 End If 'własciwe sterowanie silnikami i bloki operacyjne dla silników i pid Angle_xx = Kat_x + Xx Angle_yy = Kat_y + Yy 'wstępne dane do filtra pid Pv1 = Moc + Angle_xx Pv2 = Moc + Angle_yy Pv3 = Moc - Angle_xx Pv4 = Moc - Angle_yy Spx1 = Moc Spx2 = Moc Spx3 = Moc Spx4 = Moc If Faza_lotu > 0 Then Error1 = Spx1 - Pv1 ' Obliczanie uchybu Error1 = Error1 * -1 ' Inwersja uchybu Sum_error1 = Sum_error1 + Error1 ' Suma uchybów Iterm1 = Ki1 * Sum_error1 ' Integrated CV part (CAŁKUJĄCY) ' -------- First time startup If First_execution1 < 2 Then If First_execution1 = 0 Then Sum_error1 = 40 / Ki1 First_execution1 = 1 Initial_error1 = Error1 End If Pterm1 = 0 Dterm1 = 0 If Initial_error1 > 0 And Error1 < 0 Then First_execution1 = 2 Last_pv1 = Pv1 End If If Initial_error1 < 0 And Error1 > 0 Then First_execution1 = 2 Last_pv1 = Pv1 End If Last_sp1 = Spx1 ' -------- Normal calculation loop Else D_pv1 = Last_pv1 - Pv1 Last_pv1 = Pv1 Dterm1 = Kd1 * D_pv1 ' Derivated CV part If Spx1 = Last_sp1 Then ' -------- Normal loop when setpoint not changed Pterm1 = Kp1 * Error1 ' Proportional CV part ' -------- Loop when setpoint changed Else Pterm1 = 0 Dterm1 = 0 If Spx1 > Last_sp1 And Pv1 > Spx1 Then Last_sp1 = Spx1 Last_pv1 = Pv1 End If If Spx1 < Last_sp1 And Pv1 < Spx1 Then Last_sp1 = Spx1 Last_pv1 = Pv1 End If End If ' Enf of SP change seperation ' End If ' Enf of first time running seperation ' Cv1 = Pterm1 + Iterm1 ' Summing of the tree Cv1 = Cv1 + Dterm1 ' calculated terms ' --------End normal calculation loop Error2 = Spx2 - Pv2 ' Obliczanie uchybu Error2 = Error2 * -1 ' Inwersja uchybu Sum_error2 = Sum_error2 + Error2 ' Suma uchybów Iterm2 = Ki2 * Sum_error2 ' Integrated CV part (CAŁKUJĄCY) ' -------- First time startup If First_execution2 < 2 Then If First_execution2 = 0 Then Sum_error2 = 40 / Ki2 First_execution2 = 1 Initial_error2 = Error2 End If Pterm2 = 0 Dterm2 = 0 If Initial_error2 > 0 And Error2 < 0 Then First_execution2 = 2 Last_pv2 = Pv2 End If If Initial_error2 < 0 And Error2 > 0 Then First_execution2 = 2 Last_pv2 = Pv2 End If Last_sp2 = Spx2 ' -------- Normal calculation loop Else D_pv2 = Last_pv2 - Pv2 Last_pv2 = Pv2 Dterm2 = Kd2 * D_pv2 ' Derivated CV part If Spx2 = Last_sp2 Then ' -------- Normal loop when setpoint not changed Pterm2 = Kp2 * Error2 ' Proportional CV part ' -------- Loop when setpoint changed Else Pterm2 = 0 Dterm2 = 0 If Spx2 > Last_sp2 And Pv2 > Spx2 Then Last_sp2 = Spx2 Last_pv2 = Pv2 End If If Spx2 < Last_sp2 And Pv2 < Spx2 Then Last_sp2 = Spx2 Last_pv2 = Pv2 End If End If ' Enf of SP change seperation ' End If ' Enf of first time running seperation ' Cv2 = Pterm2 + Iterm2 ' Summing of the tree Cv2 = Cv2 + Dterm2 ' calculated terms ' --------End normal calculation loop Error3 = Spx3 - Pv3 ' Obliczanie uchybu Error3 = Error3 * -1 ' Inwersja uchybu Sum_error3 = Sum_error3 + Error3 ' Suma uchybów Iterm3 = Ki1 * Sum_error3 ' Integrated CV part (CAŁKUJĄCY) ' -------- First time startup If First_execution3 < 2 Then If First_execution3 = 0 Then Sum_error3 = 40 / Ki1 First_execution3 = 1 Initial_error3 = Error3 End If Pterm3 = 0 Dterm3 = 0 If Initial_error3 > 0 And Error3 < 0 Then First_execution3 = 2 Last_pv3 = Pv3 End If If Initial_error3 < 0 And Error3 > 0 Then First_execution3 = 2 Last_pv3 = Pv3 End If Last_sp3 = Spx3 ' -------- Normal calculation loop Else D_pv3 = Last_pv3 - Pv3 Last_pv3 = Pv3 Dterm3 = Kd1 * D_pv3 ' Derivated CV part If Spx3 = Last_sp3 Then ' -------- Normal loop when setpoint not changed Pterm3 = Kp1 * Error3 ' Proportional CV part ' -------- Loop when setpoint changed Else Pterm3 = 0 Dterm3 = 0 If Spx3 > Last_sp3 And Pv3 > Spx3 Then Last_sp3 = Spx3 Last_pv3 = Pv3 End If If Spx3 < Last_sp3 And Pv3 < Spx3 Then Last_sp3 = Spx3 Last_pv3 = Pv3 End If End If ' Enf of SP change seperation ' End If ' Enf of first time running seperation ' Cv3 = Pterm3 + Iterm3 ' Summing of the tree Cv3 = Cv3 + Dterm3 ' calculated terms ' --------End normal calculation loop Error4 = Spx4 - Pv4 ' Obliczanie uchybu Error4 = Error4 * -4 ' Inwersja uchybu Sum_error4 = Sum_error4 + Error4 ' Suma uchybów Iterm4 = Ki2 * Sum_error4 ' Integrated CV part (CAŁKUJĄCY) ' -------- First time startup If First_execution4 < 2 Then If First_execution4 = 0 Then Sum_error4 = 40 / Ki2 First_execution4 = 1 Initial_error4 = Error4 End If Pterm4 = 0 Dterm4 = 0 If Initial_error4 > 0 And Error4 < 0 Then First_execution4 = 2 Last_pv4 = Pv2 End If If Initial_error4 < 0 And Error4 > 0 Then First_execution4 = 2 Last_pv4 = Pv4 End If Last_sp4 = Spx4 ' -------- Normal calculation loop Else D_pv4 = Last_pv4 - Pv4 Last_pv4 = Pv4 Dterm4 = Kd2 * D_pv4 ' Derivated CV part If Spx4 = Last_sp4 Then ' -------- Normal loop when setpoint not changed Pterm4 = Kp2 * Error4 ' Proportional CV part ' -------- Loop when setpoint changed Else Pterm4 = 0 Dterm4 = 0 If Spx4 > Last_sp4 And Pv4 > Spx4 Then Last_sp4 = Spx4 Last_pv4 = Pv4 End If If Spx4 < Last_sp4 And Pv4 < Spx4 Then Last_sp4 = Spx4 Last_pv4 = Pv4 End If End If ' Enf of SP change seperation ' End If ' Enf of first time running seperation ' Cv4 = Pterm4 + Iterm4 ' Summing of the tree Cv4 = Cv4 + Dterm4 ' calculated terms ' --------End normal calculation loop End If If Cv1 > 130 Then Cv1 = 130 If Cv2 > 130 Then Cv2 = 130 If Cv3 > 130 Then Cv3 = 130 If Cv4 > 130 Then Cv4 = 130 If Cv1 < 63 Then Cv1 = 63 If Cv2 < 63 Then Cv2 = 63 If Cv3 < 63 Then Cv3 = 63 If Cv4 < 63 Then Cv4 = 63 If Faza_lotu = 0 Then Led3 = 0 Motor(1) = Moc Motor(2) = Moc Motor(3) = Moc Motor(4) = Moc End If If Faza_lotu = 1 Then Toggle Led3 Motor(1) = Cv1 Motor(2) = Cv2 Motor(3) = Cv3 Motor(4) = Cv4 End If If Faza_lotu = 2 Then Led3 = 1 Motor(1) = Cv1 Motor(2) = Cv2 Motor(3) = Cv3 Motor(4) = Cv4 End If If Faza_lotu = 3 Then Toggle Led3 Motor(1) = Cv1 Motor(2) = Cv2 Motor(3) = Cv3 Motor(4) = Cv4 End If If Faza_lotu = 4 Then 'insrukcja tesoowa do odpalenia z konsoli Toggle Led3 Motor(1) = Cv1 Motor(2) = Cv2 Motor(3) = Cv3 Motor(4) = Cv4 Print "kat_x " ; Angle_yy Print "kat_y " ; Angle_xx Print "ANGLE " ; Angle Print "wysokosc" ; Ob_wys End If 'ładowanie danych do silników, Servo(4) = Motor(4) Servo(3) = Motor(3) Servo(2) = Motor(2) - 6 'KOREKTA Servo(1) = Motor(1) Toggle Led1 Waitms 1 Loop
  10. Mamy bardzo wiele konkurencji które pokazują czyj robot lepszy. Niektóre nawet są już oklepane do takiego stopnia że na zawody z tej konkurencji jeżdżą tylko te same osoby a nikogo nowego nie widać. Ale gdyby zrobić konkurencję dla tych -którzy chcieli by się zmierzyć lub zobaczyć walkę na śmierć i życie , jak naj bardziej powinno coś takiego powstać. [ Dodano: 16-07-2015, 11:16 ] A tak nawiasem. Doczekamy się??
  11. Możemy zrobić identyczną konkurencję ale na mieszą skalę. Wymiary powiedzmy 15x15x15cm i zasada podobnie jak w sumo (zakaz używania palników ,sypania proszków ale za to wirujące części mogą być) To na ringu od sumo i całość zamknięta w klatce z pleksy. Pojazdy to zdalnie sterowane terminatory mające za zadanie zapchać się z ringu. A jeśli nie z ringu to zniszczyć się w drobny mak bądź sprawić by przeciwnik nie mógł się sam poruszać. Wadą było by to że stosowano by metalowe obudowy więc zakazane było by stosowanie pancerza przewodzącego prąd- pozostaną tylko kompozyty. A jeśli dać im możliwość stosowania palników trzeba by zainstalować jakiś wyciąg do ringu. Na pewno znaleźli by się chętni. Nie jest to też mój pomysł a jedynie jego interpretacja ale wydaje mi się że to być może przyszłość konkurencji pokazowych na zawodach robotyki.
  12. Ewentualnie w czasie rejestracji zawodnik wybierał by jaką nagrodę by chciał.
  13. Ten sumo ma dużą prędkość-?? Pneumatyka??
  14. Takie cudo mi się nie pojawia -to chyba przez adblocka =D
  15. Ja tam dodać robota minisumo?? PS. Pieruńska strona-ale jest.
×
×
  • Utwórz nowe...

Ważne informacje

Ta strona używa ciasteczek (cookies), dzięki którym może działać lepiej. Więcej na ten temat znajdziesz w Polityce Prywatności.